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, () => {
Source
- + { - + { :filter-option="filterOption" :bordered="false" dropdown-class-name="nc-dropdown-ltar-source-column !text-xs" - @change="onDataTypeChange" + @change="onSourceColumnChange" >
@@ -273,7 +294,7 @@ watch(pkColumn, () => {