diff --git a/packages/nc-gui-v2/components.d.ts b/packages/nc-gui-v2/components.d.ts index 88ada17810..616a5615f8 100644 --- a/packages/nc-gui-v2/components.d.ts +++ b/packages/nc-gui-v2/components.d.ts @@ -40,6 +40,8 @@ declare module '@vue/runtime-core' { AModal: typeof import('ant-design-vue/es')['Modal'] APagination: typeof import('ant-design-vue/es')['Pagination'] APopconfirm: typeof import('ant-design-vue/es')['Popconfirm'] + ARadio: typeof import('ant-design-vue/es')['Radio'] + ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup'] ARate: typeof import('ant-design-vue/es')['Rate'] ARow: typeof import('ant-design-vue/es')['Row'] ASelect: typeof import('ant-design-vue/es')['Select'] diff --git a/packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue b/packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue index 3f196a7af4..8d94bdf1eb 100644 --- a/packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue +++ b/packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue @@ -94,6 +94,7 @@ watchEffect(() => { +
+import type { TableType } from 'nocodb-sdk' +import { ModelTypes, MssqlUi, SqliteUi } from 'nocodb-sdk' +import { useColumnCreateStoreOrThrow } from '#imports' +import { MetaInj } from '~/context' +import MdiPlusIcon from '~icons/mdi/plus-circle-outline' +import MdiMinusIcon from '~icons/mdi/minus-circle-outline' + +const { formState, validateInfos, onDataTypeChange, setAdditionalValidations } = $(useColumnCreateStoreOrThrow()) +const { tables, sqlUi } = $(useProject()) +const meta: TableType = $(inject(MetaInj)) + +console.log(tables) + +setAdditionalValidations({ + childId: [{ required: true, message: 'Required' }], +}) + +const onUpdateDeleteOptions = sqlUi === MssqlUi ? ['NO ACTION'] : ['NO ACTION', 'CASCADE', 'RESTRICT', 'SET NULL', 'SET DEFAULT'] + +if (!formState.parentId) formState.parentId = meta.id +if (!formState.childId) formState.childId = null +if (!formState.childColumn) formState.childColumn = `${meta.table_name}_id` +if (!formState.childTable) formState.childTable = meta.table_name +if (!formState.parentTable) formState.parentTable = formState.rtn || '' +if (!formState.parentColumn) formState.parentColumn = formState.rcn || '' + +if (!formState.type) formState.type = 'hm' +if (!formState.onUpdate) formState.onUpdate = onUpdateDeleteOptions[0] +if (!formState.onDelete) formState.onDelete = onUpdateDeleteOptions[0] +if (!formState.virtual) formState.virtual = sqlUi === SqliteUi +if (!formState.alias) formState.alias = formState.column_name + +const advancedOptions = $(ref(false)) + +const refTables = $computed(() => { + if (!tables || !tables.length) { + return [] + } + + return tables.filter((t) => t.type === ModelTypes.TABLE) +}) + + + + +