diff --git a/packages/nc-gui-v2/components/smartsheet/Form.vue b/packages/nc-gui-v2/components/smartsheet/Form.vue index f0671dc41d..ed9f5c070f 100644 --- a/packages/nc-gui-v2/components/smartsheet/Form.vue +++ b/packages/nc-gui-v2/components/smartsheet/Form.vue @@ -43,14 +43,15 @@ const { loadData, paginationData, formattedData: data, - loadFormData, - formData, + loadFormView, + formColumnData, + formViewData, changePage, updateRowProperty, } = useViewData(meta, view as any) const { showAll, hideAll, saveOrUpdate } = useViewColumns(view, meta as any, false, () => { - loadFormData() + loadFormView() setFormData() }) @@ -58,10 +59,12 @@ const columns = computed(() => meta?.value?.columns || []) const localColumns = ref>([]) -const hiddenColumns = computed(() => []) +const hiddenColumns = ref>([]) const availableColumns = inject(FieldsInj, ref([])) +const systemFieldsIds = ref>([]) + const formView = ref({}) function updateView() {} @@ -94,7 +97,7 @@ function isDbRequired(column: Record) { string, any > - if ((col.rqd && !col.default) || formState?.fields[column.title]?.required) { + if ((col.rqd && !col.default) || (formState as Record)?.fields[column.title]?.required) { isRequired = true } } @@ -154,31 +157,38 @@ async function checkSMTPStatus() {} function setFormData() { Object.assign(formState, { - heading: formData.value?.heading, - subheading: formData.value?.subheading, - submit_another_form: !!formData.value?.submit_another_form, - show_blank_form: !!formData.value?.email, - email: formData.value?.submit_another_form, - success_msg: formData.value?.success_msg, - fields: (formData.value as Record[])?.map((c) => ({ + heading: formViewData.value?.heading, + subheading: formViewData.value?.subheading, + submit_another_form: !!formViewData.value?.submit_another_form, + show_blank_form: !!formViewData.value?.email, + email: formViewData.value?.submit_another_form, + success_msg: formViewData.value?.success_msg, + fields: (formColumnData.value as Record[])?.map((c) => ({ [c.title]: { required: false, }, })), }) - localColumns.value = (formData as Record)?.value + + const col = (formColumnData as Record)?.value + + localColumns.value = col .filter((f: Record) => f.show && f.uidt !== UITypes.Rollup && f.uidt !== UITypes.Lookup) .sort((a: Record, b: Record) => a.order - b.order) + + systemFieldsIds.value = getSystemColumns(col).map((c: Record) => c.fk_column_id) + + hiddenColumns.value = col.filter((f: Record) => !f.show && !systemFieldsIds.value.includes(f.fk_column_id)) } onMounted(async () => { - await loadFormData() + await loadFormView() setFormData() }) // TODO: check if it's required watch( - () => formData, + () => formColumnData || formViewData, (v) => { setFormData() }, @@ -197,11 +207,21 @@ watch(
- + {{ $t('general.addAll') }} - + {{ $t('general.removeAll') }} @@ -209,12 +229,12 @@ watch(
-