From 1b04bac81756e4e7c53f0ad9c28e4af10e2e6d4d Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:22:02 +0000 Subject: [PATCH] fix(nc-gui): on toggle validate field error --- .../smartsheet/column/LinkAdvancedOptions.vue | 66 ++++++++++++++----- .../column/LinkedToAnotherRecordOptions.vue | 5 +- .../composables/useColumnCreateStore.ts | 12 ++-- 3 files changed, 58 insertions(+), 25 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/column/LinkAdvancedOptions.vue b/packages/nc-gui/components/smartsheet/column/LinkAdvancedOptions.vue index a82afcc925..a82f391c2f 100644 --- a/packages/nc-gui/components/smartsheet/column/LinkAdvancedOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/LinkAdvancedOptions.vue @@ -35,7 +35,7 @@ const meta = inject(MetaInj, ref({} as TableType)) const vModel = useVModel(props, 'value', emit) -const { validateInfos, setAdditionalValidations, onDataTypeChange } = useColumnCreateStoreOrThrow() +const { validateInfos, onDataTypeChange } = useColumnCreateStoreOrThrow() // const baseStore = useBase() // const { base } = storeToRefs(baseStore) @@ -55,7 +55,6 @@ vModel.value.custom = { junc_base_id: meta.value?.base_id, } -console.log('meta', meta.value, vModel.value) const { basesList, bases } = storeToRefs(useBases()) const tablesStore = useTablesStore() const { baseTables, activeTable, activeTables: sourceTables } = storeToRefs(tablesStore) @@ -121,17 +120,36 @@ const juncTableColumns = computed(() => { const filterOption = (value: string, option: { key: string }) => option.key.toLowerCase().includes(value.toLowerCase()) -const resetSelectedColumns = (isJunction: boolean = false) => { +const resetSelectedColumns = (isJunction: boolean = false, resetOnChangeDataType: boolean = false) => { if (isJunction) { if (vModel.value.custom.junc_column_id) { - vModel.value.custom.junc_column_id = null + if (resetOnChangeDataType) { + if (sourceColumn.value?.dt !== juncTableColumns.value.find((c) => c.id === vModel.value.custom.junc_column_id)?.dt) { + vModel.value.custom.junc_column_id = null + } + } else { + vModel.value.custom.junc_column_id = null + } } + if (vModel.value.custom.junc_ref_column_id) { - vModel.value.custom.junc_ref_column_id = null + if (resetOnChangeDataType) { + if (sourceColumn.value?.dt !== juncTableColumns.value.find((c) => c.id === vModel.value.custom.junc_ref_column_id)?.dt) { + vModel.value.custom.junc_ref_column_id = null + } + } else { + vModel.value.custom.junc_ref_column_id = null + } } } else { if (vModel.value.custom.ref_column_id) { - vModel.value.custom.ref_column_id = null + if (resetOnChangeDataType) { + if (sourceColumn.value?.dt !== refTableColumns.value.find((c) => c.id === vModel.value.custom.ref_column_id)?.dt) { + vModel.value.custom.ref_column_id = null + } + } else { + vModel.value.custom.ref_column_id = null + } } } } @@ -159,6 +177,12 @@ const onBaseChange = async (baseId, isJunctionBase: boolean = false) => { } } +const onSourceColumnChange = async () => { + await onDataTypeChange() + resetSelectedColumns(true, true) + resetSelectedColumns(false, true) +} + const getBaseIconColor = (base, selectedBaseId) => { if (base.id === selectedBaseId) { return undefined @@ -183,7 +207,7 @@ watch(pkColumn, () => {