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. 51
      packages/nc-gui/composables/useSharedFormViewStore.ts

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

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

Loading…
Cancel
Save