diff --git a/packages/nc-gui/components/general/DeleteModal.vue b/packages/nc-gui/components/general/DeleteModal.vue index 7dde819a81..e1f8908b9a 100644 --- a/packages/nc-gui/components/general/DeleteModal.vue +++ b/packages/nc-gui/components/general/DeleteModal.vue @@ -56,7 +56,13 @@ onKeyStroke('Enter', () => { - +
{{ $t('general.cancel') }} diff --git a/packages/nc-gui/components/nc/Select.vue b/packages/nc-gui/components/nc/Select.vue index 9766df1312..4d887c30f1 100644 --- a/packages/nc-gui/components/nc/Select.vue +++ b/packages/nc-gui/components/nc/Select.vue @@ -1,17 +1,25 @@ + + diff --git a/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue b/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue index fb48c2f781..9b3d485414 100644 --- a/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue @@ -47,9 +47,18 @@ if (!isEdit.value) { if (!vModel.value.onDelete) vModel.value.onDelete = onUpdateDeleteOptions[0] if (!vModel.value.virtual) vModel.value.virtual = sqlUi === SqliteUi // appInfo.isCloud || sqlUi === SqliteUi if (!vModel.value.alias) vModel.value.alias = vModel.value.column_name +} else { + if (!vModel.value.childId) + vModel.custom = { + ref_model_id: vModel.value?.colOptions?.fk_related_model_id, + base_id: meta.value?.base_id, + junc_base_id: meta.value?.base_id, + } + if (!vModel.value.childViewId) vModel.value.childViewId = vModel.value?.colOptions?.fk_target_view_id || null } if (!vModel.value.childId) vModel.value.childId = vModel.value?.colOptions?.fk_related_model_id || null if (!vModel.value.childViewId) vModel.value.childViewId = vModel.value?.colOptions?.fk_target_view_id || null +if (!vModel.value.type) vModel.value.type = vModel.value?.colOptions?.type || 'mm' const advancedOptions = ref(false) @@ -157,6 +166,41 @@ const handleUpdateRefTable = () => { updateFieldName() }) } + +const isAdvancedOptionsShownEasterEgg = ref(false) + +const cusValidators = { + 'custom.column_id': [{ required: true, message: t('general.required') }], + 'custom.ref_model_id': [{ required: true, message: t('general.required') }], + 'custom.ref_column_id': [{ required: true, message: t('general.required') }], +} + +const cusJuncTableValidations = { + 'custom.junc_model_id': [{ required: true, message: t('general.required') }], + 'custom.junc_column_id': [{ required: true, message: t('general.required') }], + 'custom.junc_ref_column_id': [{ required: true, message: t('general.required') }], +} + +const onCustomSwitchToggle = () => { + if (vModel.value?.is_custom_link) + setAdditionalValidations({ + childId: [], + ...cusValidators, + ...(vModel.value.type === RelationTypes.MANY_TO_MANY ? cusJuncTableValidations : {}), + }) + else + setAdditionalValidations({ + childId: [{ required: true, message: t('general.required') }], + }) +} + +const handleShowAdvanceOptions = () => { + isAdvancedOptionsShownEasterEgg.value = !isAdvancedOptionsShownEasterEgg.value + + if (!isAdvancedOptionsShownEasterEgg.value) { + vModel.value.is_custom_link = false + } +} diff --git a/packages/nc-gui/components/smartsheet/header/Menu.vue b/packages/nc-gui/components/smartsheet/header/Menu.vue index cb6ab3b9a9..7b1aa6f119 100644 --- a/packages/nc-gui/components/smartsheet/header/Menu.vue +++ b/packages/nc-gui/components/smartsheet/header/Menu.vue @@ -328,7 +328,8 @@ const isDuplicateAllowed = computed(() => { return ( column?.value && !column.value.system && - ((!isMetaReadOnly.value && !isDataReadOnly.value) || readonlyMetaAllowedTypes.includes(column.value?.uidt)) + ((!isMetaReadOnly.value && !isDataReadOnly.value) || readonlyMetaAllowedTypes.includes(column.value?.uidt)) && + !column.value.meta?.custom ) }) const isFilterSupported = computed( @@ -373,6 +374,13 @@ const isColumnEditAllowed = computed(() => { return false return true }) + +// check if the column is associated as foreign key in any of the link column +const linksAssociated = computed(() => { + return meta.value?.columns?.filter( + (c) => isLinksOrLTAR(c) && [c.colOptions?.fk_child_column_id, c.colOptions?.fk_parent_column_id].includes(column?.value?.id), + ) +})