Browse Source

feat(nc-gui): prefill form with default values

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

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

@ -124,11 +124,17 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
{} as Record<string, FormColumnType>, {} as Record<string, FormColumnType>,
) )
columns.value = viewMeta.model?.columns?.map((c) => ({ columns.value = viewMeta.model?.columns?.map((c) => {
if (!isSystemColumn(c) && !isVirtualCol(c) && c?.title && c?.cdf) {
formState.value[c.title] = c.cdf
}
return {
...c, ...c,
meta: { ...parseProp(fieldById[c.id].meta), ...parseProp(c.meta) }, meta: { ...parseProp(fieldById[c.id].meta), ...parseProp(c.meta) },
description: fieldById[c.id].description, description: fieldById[c.id].description,
})) }
})
const _sharedViewMeta = (viewMeta as any).meta const _sharedViewMeta = (viewMeta as any).meta
sharedViewMeta.value = isString(_sharedViewMeta) ? JSON.parse(_sharedViewMeta) : _sharedViewMeta sharedViewMeta.value = isString(_sharedViewMeta) ? JSON.parse(_sharedViewMeta) : _sharedViewMeta
@ -262,7 +268,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
function handlePreFillForm() { function handlePreFillForm() {
if (Object.keys(route.query).length && sharedViewMeta.value.preFillEnabled) { if (Object.keys(route.query).length && sharedViewMeta.value.preFillEnabled) {
columns.value = columns.value?.map((c) => { columns.value = columns.value.map((c) => {
const queryParam = route.query?.[c.title as string] || route.query?.[encodeURIComponent(c.title as string)] const queryParam = route.query?.[c.title as string] || route.query?.[encodeURIComponent(c.title as string)]
if ( if (
!c.title || !c.title ||

Loading…
Cancel
Save