diff --git a/packages/nc-gui-v2/components/smartsheet/Form.vue b/packages/nc-gui-v2/components/smartsheet/Form.vue index 0cf88732b5..f0671dc41d 100644 --- a/packages/nc-gui-v2/components/smartsheet/Form.vue +++ b/packages/nc-gui-v2/components/smartsheet/Form.vue @@ -49,15 +49,18 @@ const { updateRowProperty, } = useViewData(meta, view as any) -const { saveOrUpdate } = useViewColumns(view, meta as any, false) +const { showAll, hideAll, saveOrUpdate } = useViewColumns(view, meta as any, false, () => { + loadFormData() + setFormData() +}) const columns = computed(() => meta?.value?.columns || []) -const hiddenColumns = computed(() => []) +const localColumns = ref>([]) -const filteredColumns = computed(() => []) +const hiddenColumns = computed(() => []) -const fields = inject(FieldsInj, ref([])) +const availableColumns = inject(FieldsInj, ref([])) const formView = ref({}) @@ -126,19 +129,19 @@ function onMove(event: any) { } function hideColumn(idx: number) { - if (isDbRequired(columns.value[idx])) { + if (isDbRequired(localColumns.value[idx])) { toast.info("Required field can't be removed") return } saveOrUpdate( { - ...columns.value[idx], + ...localColumns.value[idx], show: false, }, idx, ) - ;(columns.value[idx] as any).show = false + ;(localColumns.value[idx] as any).show = false $e('a:form-view:hide-columns') } @@ -157,12 +160,15 @@ function setFormData() { show_blank_form: !!formData.value?.email, email: formData.value?.submit_another_form, success_msg: formData.value?.success_msg, - fields: fields.value.map((c: Record) => ({ + fields: (formData.value as Record[])?.map((c) => ({ [c.title]: { required: false, }, })), }) + localColumns.value = (formData as Record)?.value + .filter((f: Record) => f.show && f.uidt !== UITypes.Rollup && f.uidt !== UITypes.Lookup) + .sort((a: Record, b: Record) => a.order - b.order) } onMounted(async () => { @@ -182,7 +188,6 @@ watch(