diff --git a/packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue b/packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue index 949cb1ecb5..29ce9f57f8 100644 --- a/packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue +++ b/packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue @@ -92,6 +92,7 @@ watchEffect(() => { +
+import { UITypes, isSystemColumn } from 'nocodb-sdk' +import { useColumnCreateStoreOrThrow } from '#imports' +import { MetaInj } from '~/context' + +const { formState, validateInfos, onDataTypeChange, setAdditionalValidations } = $(useColumnCreateStoreOrThrow()) +const { tables } = $(useProject()) +const meta = $(inject(MetaInj)) +const { metas } = $(useMetas()) + +setAdditionalValidations({ + fk_relation_column_id: [{ required: true, message: 'Required' }], + fk_lookup_column_id: [{ required: true, message: 'Required' }], +}) + +if (!formState.fk_relation_column_id) formState.fk_relation_column_id = null +if (!formState.fk_lookup_column_id) formState.fk_lookup_column_id = null + +const relationNames = { + mm: 'Many To Many', + hm: 'Has Many', + bt: 'Belongs To', +} + +const refTables = $computed(() => { + if (!tables || !tables.length) { + return [] + } + + return meta.columns + .filter((c) => c.uidt === UITypes.LinkToAnotherRecord && c.colOptions.type !== 'bt' && !c.system) + .map((c) => ({ + col: c.colOptions, + column: c, + ...tables.find((t) => t.id === c.colOptions.fk_related_model_id), + })) + .filter((table) => table.col.fk_related_model_id === table.id && !table.mm) +}) + +const columns = $computed(() => { + const selectedTable = refTables.find((t) => t.column.id === formState.fk_relation_column_id) + if (!selectedTable?.id) { + return [] + } + + return metas[selectedTable.id].columns.filter((c) => !isSystemColumn(c)) +}) + + + + + + diff --git a/packages/nc-gui-v2/components/smartsheet/VirtualCell.vue b/packages/nc-gui-v2/components/smartsheet/VirtualCell.vue index 8cb234b3c4..24e8967347 100644 --- a/packages/nc-gui-v2/components/smartsheet/VirtualCell.vue +++ b/packages/nc-gui-v2/components/smartsheet/VirtualCell.vue @@ -1,7 +1,7 @@ @@ -31,6 +31,7 @@ const { isLookup, isBt, isRollup, isMm, isHm, isFormula, isCount } = useVirtualC +
diff --git a/packages/nc-gui-v2/components/tabs/auth/user-management/UsersModal.vue b/packages/nc-gui-v2/components/tabs/auth/user-management/UsersModal.vue index 58ff8dd93d..854b3f617a 100644 --- a/packages/nc-gui-v2/components/tabs/auth/user-management/UsersModal.vue +++ b/packages/nc-gui-v2/components/tabs/auth/user-management/UsersModal.vue @@ -41,7 +41,7 @@ const validators = computed(() => { emails: [ { validator: (rule: any, value: string, callback: (errMsg?: string) => void) => { - if (value.length === 0) { + if (!value || value.length === 0) { callback('Email is required') return } diff --git a/packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue b/packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue index d6ed4a43a7..7ccd995023 100644 --- a/packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue +++ b/packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue @@ -1,11 +1,11 @@ + + +
+ + - --> + + - - - diff --git a/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue b/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue index e7ea737029..909fb880bd 100644 --- a/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue +++ b/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue @@ -1,11 +1,11 @@