Browse Source

fix(nc-gui): allow prefill date, datetime, time only in iso format

pull/7786/head
Ramesh Mane 9 months ago
parent
commit
a798b55eab
  1. 33
      packages/nc-gui/composables/useSharedFormViewStore.ts

33
packages/nc-gui/composables/useSharedFormViewStore.ts

@ -277,6 +277,11 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
return c return c
} }
const preFillValue = getPreFillValue(c, (route.query?.[c.title] as string).trim())
if (preFillValue !== undefined) {
// Prefill form state
formState.value[c.title] = preFillValue
// Update column // Update column
switch (sharedViewMeta.value.preFilledMode) { switch (sharedViewMeta.value.preFilledMode) {
case PreFilledMode.Hidden: { case PreFilledMode.Hidden: {
@ -288,11 +293,6 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
break break
} }
} }
// Prefill form state
const preFillValue = getPreFillValue(c, (route.query?.[c.title] as string).trim())
if (preFillValue !== undefined) {
formState.value[c.title] = preFillValue
} }
return c return c
@ -398,19 +398,22 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
} }
break break
} }
case UITypes.Date: case UITypes.Date: {
const parsedDate = dayjs(value, 'YYYY-MM-DD')
if (parsedDate.isValid()) {
preFillValue = parsedDate.format('YYYY-MM-DD')
}
break
}
case UITypes.DateTime: { case UITypes.DateTime: {
let parsedDateOrDateTime = dayjs(value, getDateTimeFormat(value)) let parsedDateTime = dayjs(value, 'YYYY-MM-DD HH:mm:ss')
if (!parsedDateOrDateTime.isValid()) { if (parsedDateTime.isValid()) {
parsedDateOrDateTime = dayjs(value, getDateFormat(value)) preFillValue = parsedDateTime.utc().format('YYYY-MM-DD HH:mm:ssZ')
} else if (dayjs(value).toISOString() === value) {
if (parsedDateTime.isValid() && parsedDateTime.toISOString() === value) {
preFillValue = dayjs(value).format('YYYY-MM-DD HH:mm:ssZ')
} }
if (parsedDateOrDateTime.isValid()) {
preFillValue =
c.uidt === UITypes.Date
? parsedDateOrDateTime.format('YYYY-MM-DD')
: parsedDateOrDateTime.utc().format('YYYY-MM-DD HH:mm:ssZ')
} }
break break
} }

Loading…
Cancel
Save