Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nc feat/links from existing cols #8367

Open
wants to merge 59 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
cad8a12
feat: custom link creation
pranavxc May 2, 2024
8b8a1c8
feat: custom relation
pranavxc May 2, 2024
64051df
feat: custom relation - WIP
pranavxc May 2, 2024
fb87624
fix: reload meta after link creation
pranavxc May 2, 2024
a610878
fix: avoid deleting foreign key when it's a custom link
pranavxc May 2, 2024
2de9a98
refactor: avoid nested blocks
pranavxc May 2, 2024
c741e5a
fix: move fk column delete inside condition block
pranavxc May 2, 2024
9604954
feat: relation across bases
pranavxc May 2, 2024
4b31c12
fix: one-to-one excluded list issue
pranavxc May 2, 2024
ae3aa98
fix: belongs to link delete issue
pranavxc May 2, 2024
765aa37
fix: lookup - interbase link
pranavxc May 2, 2024
9ca045e
fix: groupby - interbase link/lookup
pranavxc May 2, 2024
a829bba
fix: extract base id from model meta since it can belongs to npn-acti…
pranavxc May 2, 2024
60fbc06
feat: update new data link api
pranavxc May 2, 2024
26c56f9
fix(nc-gui): change relation type ui from edit column modal
rameshmane7218 May 2, 2024
fb7d5f9
feat(nc-gui): update relation type ui with new design
rameshmane7218 May 2, 2024
ac7caa8
fix(nc-gui): add relation settings tables
rameshmane7218 May 2, 2024
1407fdc
feat(nc-gui): update advance link field modal with new design
rameshmane7218 May 2, 2024
0982e41
fix(nc-gui): use grayscale base icon in relation settings field modal
rameshmane7218 May 2, 2024
64a0d24
fix(nc-gui): on toggle validate field error
rameshmane7218 May 2, 2024
57f9087
fix(nc-gui): optimize nc select component
rameshmane7218 May 2, 2024
03e84e1
fix(nc-gui): replace component a-select with NcSelect
rameshmane7218 May 2, 2024
4fb1f9f
fix(nc-gui): add advance relation setting table connection line
rameshmane7218 May 2, 2024
dfbe7a2
fix(nc-gui): remove unwanted file
rameshmane7218 May 2, 2024
2f19418
fix(nc-gui): relation settings tables changes
rameshmane7218 May 2, 2024
46e509d
fix(nc-gui): resize icons size to align with text size
rameshmane7218 May 2, 2024
ed92052
fix(nc-gui): update chevron icon size
rameshmane7218 May 2, 2024
5df67af
test: unit test
pranavxc May 2, 2024
9e284f1
test: playwright test - WIP
pranavxc May 2, 2024
94411f4
test: playwright test - WIP
pranavxc May 2, 2024
5526260
test: fix typo
dstala May 2, 2024
eb0de18
fix: check column is associated with any link before deleting
pranavxc May 2, 2024
6441ca3
fix: allow columns as foreign key when abstract types matches
pranavxc May 2, 2024
73f1cf2
test: corrections
pranavxc May 2, 2024
9ef4913
test: unit test corrections
pranavxc May 2, 2024
73c9843
fix: null handling
pranavxc May 2, 2024
a181092
fix: delete custom relation on junction table delete/ fk column delete
pranavxc May 2, 2024
bce7d1c
fix: show error while deleting junction table used in a custom relation
pranavxc May 2, 2024
b6387ef
fix: show error while deleting column used in a custom relation
pranavxc May 2, 2024
86dcb48
fix: show error while deleting column used in a custom relation
pranavxc May 2, 2024
5bf8412
fix: one to one relation in new record expand modal
pranavxc May 2, 2024
25379fb
fix: disable duplicate option for custom link
pranavxc May 2, 2024
b07fe5b
fix: column deletion correction
pranavxc May 2, 2024
36b962f
fix: column deletion correction
pranavxc May 2, 2024
090ef60
fix: include error code
pranavxc May 2, 2024
7fbbb0d
fix: check column within same table first
pranavxc May 2, 2024
2418db2
fix: get relation column information properly
pranavxc May 2, 2024
76d49f4
fix: proper use of xcCondition
pranavxc May 2, 2024
bbf71df
fix: rebase corrections
pranavxc May 2, 2024
9a763ee
fix: delete column from related table, exclude system fields from option
pranavxc May 2, 2024
1f58c6d
fix: handle null case
pranavxc May 2, 2024
199322f
refactor: cleanup
pranavxc May 2, 2024
d5ecf5c
test: disable advance options
dstala May 2, 2024
f054879
test: fix mm-hm order
dstala May 2, 2024
d3aa932
refactor: use `tables` reactive var and if not found then look in metas
pranavxc May 2, 2024
fb5e4e0
chore: lint
pranavxc May 2, 2024
878ca41
fix: import statement correction
pranavxc May 2, 2024
e13413a
feat: add warning slot
pranavxc May 2, 2024
464cc4f
Merge branch 'develop' into nc-feat/links-from-existing-cols
dstala May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/nc-gui/components/general/DeleteModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ onKeyStroke('Enter', () => {
</div>

<slot name="entity-preview"></slot>

<template v-if="$slots.warning">
<a-alert type="warning" show-icon>
<template #message>
<slot name="warning"></slot>
</template>
</a-alert>
</template>
<div class="flex flex-row gap-x-2 mt-2.5 pt-2.5 justify-end">
<NcButton type="secondary" @click="visible = false">
{{ $t('general.cancel') }}
Expand Down
46 changes: 23 additions & 23 deletions packages/nc-gui/components/nc/Select.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
<script lang="ts" setup>
const props = defineProps<{
value?: string | string[]
placeholder?: string
mode?: 'multiple' | 'tags'
size?: 'small' | 'middle' | 'large'
dropdownClassName?: string
showSearch?: boolean
// filterOptions is a function
filterOption?: (input: string, option: any) => boolean
dropdownMatchSelectWidth?: boolean
allowClear?: boolean
loading?: boolean
}>()
import type { iconMap } from '#imports'

const props = withDefaults(
defineProps<{
value?: string | string[]
placeholder?: string
mode?: 'multiple' | 'tags'
size?: 'small' | 'middle' | 'large'
dropdownClassName?: string
showSearch?: boolean
// filterOptions is a function
filterOption?: (input: string, option: any) => boolean
dropdownMatchSelectWidth?: boolean
allowClear?: boolean
loading?: boolean
suffixIcon?: keyof typeof iconMap
}>(),
{
suffixIcon: 'arrowDown',
},
)

const emits = defineEmits(['update:value', 'change'])

Expand All @@ -25,15 +33,7 @@ const dropdownClassName = computed(() => {
return className
})

const showSearch = computed(() => props.showSearch)

const filterOption = computed(() => props.filterOption)

const dropdownMatchSelectWidth = computed(() => props.dropdownMatchSelectWidth)

const loading = computed(() => props.loading)

const mode = computed(() => props.mode)
const { showSearch, filterOption, dropdownMatchSelectWidth, loading, mode } = toRefs(props)

const vModel = useVModel(props, 'value', emits)

Expand All @@ -60,7 +60,7 @@ const onChange = (value: string) => {
>
<template #suffixIcon>
<GeneralLoader v-if="loading" />
<GeneralIcon v-else class="text-gray-800 nc-select-expand-btn" icon="arrowDown" />
<GeneralIcon v-else class="text-gray-800 nc-select-expand-btn" :icon="suffixIcon" />
</template>
<slot />
</a-select>
Expand Down
6 changes: 5 additions & 1 deletion packages/nc-gui/components/smartsheet/Cell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ const { currentRow } = useSmartsheetRowStoreOrThrow()

const { sqlUis } = storeToRefs(useBase())

const sqlUi = ref(column.value?.source_id ? sqlUis.value[column.value?.source_id] : Object.values(sqlUis.value)[0])
const sqlUi = ref(
column.value?.source_id && sqlUis.value[column.value?.source_id]
? sqlUis.value[column.value?.source_id]
: Object.values(sqlUis.value)[0],
)

const abstractType = computed(() => column.value && sqlUi.value.getAbstractType(column.value))

Expand Down
6 changes: 5 additions & 1 deletion packages/nc-gui/components/smartsheet/PlainCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ const { basesUser } = storeToRefs(basesStore)

const { isXcdbBase, isMssql, isMysql } = useBase()

const sqlUi = ref(column.value?.source_id ? sqlUis.value[column.value?.source_id] : Object.values(sqlUis.value)[0])
const sqlUi = ref(
column.value?.source_id && sqlUis.value[column.value?.source_id]
? sqlUis.value[column.value?.source_id]
: Object.values(sqlUis.value)[0],
)

const abstractType = computed(() => column.value && sqlUi.value.getAbstractType(column.value))

Expand Down
1 change: 1 addition & 0 deletions packages/nc-gui/components/smartsheet/column/EditOrAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ if (props.fromTableExplorer) {
'!w-146': isTextArea(formState) && formState.meta?.richMode,
'!w-116 overflow-visible': formState.uidt === UITypes.Formula && !props.embedMode,
'!w-[500px]': formState.uidt === UITypes.Attachment && !props.embedMode && !appInfo.ee,
'min-w-[422px] !w-full': isLinksOrLTAR(formState.uidt),
'shadow-lg border-1 border-gray-200 shadow-gray-300 rounded-xl p-6': !embedMode,
}"
@keydown="handleEscape"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script setup lang="ts">
defineProps<{
value: any
}>()
</script>

<template>
<span></span>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -55,45 +55,114 @@ const filterOption = (value: string, option: { key: string }) => option.key.toLo
const isLinks = computed(() => vModel.value.uidt === UITypes.Links && vModel.value.type !== RelationTypes.ONE_TO_ONE)

const oneToOneEnabled = ref(false)

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
}
}
Comment on lines +59 to +92
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider simplifying the toggle logic for advanced options.

- 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
-   }
- }
+ const toggleAdvancedOptions = () => {
+   isAdvancedOptionsShownEasterEgg.value = !isAdvancedOptionsShownEasterEgg.value;
+   vModel.value.is_custom_link = isAdvancedOptionsShownEasterEgg.value;
+   setAdditionalValidations(isAdvancedOptionsShownEasterEgg.value ? {
+     childId: [],
+     ...cusValidators,
+     ...(vModel.value.type === RelationTypes.MANY_TO_MANY ? cusJuncTableValidations : {}),
+   } : {
+     childId: [{ required: true, message: t('general.required') }],
+   });
+ }

This refactoring combines the logic of onCustomSwitchToggle and handleShowAdvanceOptions into a single method, reducing redundancy and improving readability.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
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
}
}
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 toggleAdvancedOptions = () => {
isAdvancedOptionsShownEasterEgg.value = !isAdvancedOptionsShownEasterEgg.value;
vModel.value.is_custom_link = isAdvancedOptionsShownEasterEgg.value;
setAdditionalValidations(isAdvancedOptionsShownEasterEgg.value ? {
childId: [],
...cusValidators,
...(vModel.value.type === RelationTypes.MANY_TO_MANY ? cusJuncTableValidations : {}),
} : {
childId: [{ required: true, message: t('general.required') }],
});
}

Comment on lines +73 to +92
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The refactoring of the toggle logic in LinkedToAnotherRecordOptions.vue does not appear to have been implemented as expected. The old method names onCustomSwitchToggle and handleShowAdvanceOptions are still present in the file. This suggests that the suggested changes were not made or were not made correctly.

  • Location: packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue
Analysis chain

Ensure the refactored toggle logic is implemented as suggested.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the refactored toggle logic is implemented in the `LinkedToAnotherRecordOptions.vue` file.

# Test: Search for the old method names to find omissions. Expect: No matches.
rg --files-with-matches --type vue $'onCustomSwitchToggle|handleShowAdvanceOptions' packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue

Length of output: 190



Script:

#!/bin/bash
# Description: Verify that the refactored toggle logic is implemented in the `LinkedToAnotherRecordOptions.vue` file.

# Test: Search for the old method names to find omissions. Expect: No matches.
rg --files-with-matches 'onCustomSwitchToggle|handleShowAdvanceOptions' packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue

Length of output: 229

</script>

<template>
<div class="w-full flex flex-col mb-2 mt-4">
<div class="border-2 p-6">
<div class="w-full flex flex-col mb-2 mt-1">
<div class="mb-2">Relation Type <span class="text-red-500">*</span></div>
<div class="border-1 border-gray-200 rounded-lg">
<a-form-item v-bind="validateInfos.type" class="nc-ltar-relation-type">
<a-radio-group v-model:value="vModel.type" name="type" v-bind="validateInfos.type" class="!flex flex-col gap-2">
<a-radio value="hm" @dblclick="oneToOneEnabled = !oneToOneEnabled">{{ $t('title.hasMany') }}</a-radio>
<a-radio value="mm">{{ $t('title.manyToMany') }}</a-radio>
<a-radio v-if="oneToOneEnabled" value="oo">{{ $t('title.oneToOne') }}</a-radio>
<a-radio-group
v-model:value="vModel.type"
name="type"
v-bind="validateInfos.type"
class="nc-ltar-relation-type-radio-group !flex flex-col"
>
<a-radio value="mm">
<span class="nc-ltar-icon nc-mm-icon">
<GeneralIcon icon="mm" class="text-white" />
</span>
{{ $t('title.manyToMany') }}</a-radio
>
<a-radio value="hm" @dblclick="oneToOneEnabled = !oneToOneEnabled">
<span class="nc-ltar-icon nc-hm-icon"><GeneralIcon icon="hm" class="text-white" /></span>
{{ $t('title.hasMany') }}</a-radio
>

<a-radio v-if="oneToOneEnabled" value="oo" @dblclick="handleShowAdvanceOptions">
<span class="nc-ltar-icon nc-oo-icon">
<GeneralIcon icon="oneToOneSolid" class="text-white" />
</span>
{{ $t('title.oneToOne') }}</a-radio
>
</a-radio-group>
</a-form-item>

<a-form-item
class="flex w-full pb-2 mt-4 nc-ltar-child-table"
:label="$t('labels.childTable')"
v-bind="validateInfos.childId"
>
<a-select
v-model:value="vModel.childId"
show-search
:filter-option="filterOption"
dropdown-class-name="nc-dropdown-ltar-child-table"
@change="onDataTypeChange"
>
<a-select-option v-for="table of refTables" :key="table.title" :value="table.id">
<div class="flex w-full items-center gap-2">
<div class="min-w-5 flex items-center justify-center">
<GeneralTableIcon :meta="table" class="text-gray-500" />
</div>
<div v-if="isAdvancedOptionsShownEasterEgg && isEeUI" class="mt-4">
<a-switch v-model:checked="vModel.is_custom_link" size="small" name="Custom" @change="onCustomSwitchToggle" />
<span class="ml-3">Advanced Link</span>
</div>
<div
:class="{
'mt-3': isAdvancedOptionsShownEasterEgg,
'mt-4': !isAdvancedOptionsShownEasterEgg,
}"
>
<LazySmartsheetColumnLinkAdvancedOptions v-if="isEeUI && vModel.is_custom_link" v-model:value="vModel" />
<template v-else>
<a-form-item class="flex w-full pb-2 nc-ltar-child-table" v-bind="validateInfos.childId">
<a-select
v-model:value="vModel.childId"
show-search
:filter-option="filterOption"
placeholder="-select child table-"
dropdown-class-name="nc-dropdown-ltar-child-table"
@change="onDataTypeChange"
>
<a-select-option v-for="table of refTables" :key="table.title" :value="table.id">
<div class="flex w-full items-center gap-2">
<div class="min-w-5 flex items-center justify-center">
<GeneralTableIcon :meta="table" class="text-gray-500" />
</div>
<NcTooltip class="flex-1 truncate" show-on-truncate-only>
<template #title>{{ table.title }}</template>
<span>{{ table.title }}</span>
</NcTooltip>
</div>
<NcTooltip class="flex-1 truncate" show-on-truncate-only>
<template #title>{{ table.title }}</template>
<span>{{ table.title }}</span>
</NcTooltip>
</div>
</a-select-option>
</a-select>
</a-form-item>
</a-select-option>
<template #suffixIcon>
<GeneralIcon class="" icon="chevronDown" />
</template>
</a-select>
</a-form-item>
</template>
</div>

<template v-if="!isXcdbBase || isLinks">
<div
class="text-xs cursor-pointer text-grey nc-more-options my-2 flex items-center gap-1 justify-end"
Expand All @@ -105,7 +174,7 @@ const oneToOneEnabled = ref(false)
</div>

<div v-if="advancedOptions" class="flex flex-col p-6 gap-4 border-2 mt-2">
<LazySmartsheetColumnLinkOptions v-if="isLinks" v-model:value="vModel" class="-my-2" />
<LazySmartsheetColumnLinkOptions v-if="isLinks" v-model:value="vModel" class="mt-3" />
<template v-if="!isXcdbBase">
<div class="flex flex-row space-x-2">
<a-form-item class="flex w-1/2" :label="$t('labels.onUpdate')">
Expand Down Expand Up @@ -163,3 +232,39 @@ const oneToOneEnabled = ref(false)
</template>
</div>
</template>

<style lang="scss" scoped>
.nc-ltar-relation-type-radio-group {
.nc-ltar-icon {
@apply flex items-center p-1 rounded;

&.nc-mm-icon {
@apply bg-pink-500;
}
&.nc-hm-icon {
@apply bg-orange-500;
}
&.nc-oo-icon {
@apply bg-purple-500;
:deep(svg path) {
@apply stroke-purple-50;
}
}
}

:deep(.ant-radio-wrapper) {
@apply px-3 py-2 flex items-center mr-0;

&:not(:last-child) {
@apply border-b border-gray-200;
}
}

:deep(.ant-radio) {
@apply top-0;
& + span {
@apply flex items-center gap-2;
}
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ const refTables = computed(() => {
.map((column) => ({
col: column.colOptions,
column,
...tables.value.find((table) => table.id === (column.colOptions as LinkToAnotherRecordType).fk_related_model_id),
...(tables.value.find((table) => table.id === (column.colOptions as LinkToAnotherRecordType).fk_related_model_id) ||
metas.value[(column.colOptions as LinkToAnotherRecordType).fk_related_model_id!] ||
{}),
}))
.filter((table) => (table.col as LinkToAnotherRecordType)?.fk_related_model_id === table.id && !table.mm)
return _refTables as Required<TableType & { column: ColumnType; col: Required<LinkToAnotherRecordType> }>[]
Expand Down
4 changes: 4 additions & 0 deletions packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export const useColumnDrag = ({
}

const handleReorderColumn = async () => {
if (!dragColPlaceholderDomRef.value) return

dragColPlaceholderDomRef.value!.style.left = '0px'
dragColPlaceholderDomRef.value!.style.height = '0px'
await reorderColumn(draggedCol.value!.id!, toBeDroppedColId.value!)
Expand All @@ -118,6 +120,8 @@ export const useColumnDrag = ({

const dom = document.querySelector('[data-testid="drag-icon-placeholder"]')

if (!dom || !dragColPlaceholderDomRef.value) return

e.dataTransfer.dropEffect = 'none'
e.dataTransfer.effectAllowed = 'none'

Expand Down
28 changes: 28 additions & 0 deletions packages/nc-gui/components/smartsheet/header/DeleteColumnModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,31 @@ const { loadTables } = useBase()

const isLoading = ref(false)

// disable for time being - internal discussion required
/*
const warningMsg = computed(() => {
if (!column?.value) return []

const columns = meta?.value?.columns.filter((c) => {
if (isLinksOrLTAR(c) && c.colOptions) {
return (
(c.colOptions as LinkToAnotherRecordType).fk_parent_column_id === column.value?.id ||
(c.colOptions as LinkToAnotherRecordType).fk_child_column_id === column.value?.id ||
(c.colOptions as LinkToAnotherRecordType).fk_mm_child_column_id === column.value?.id ||
(c.colOptions as LinkToAnotherRecordType).fk_mm_parent_column_id === column.value?.id
)
}

return false
})

if (!columns.length) return null

return `This column is used in following Link column${columns.length > 1 ? 's' : ''}: '${columns
.map((c) => c.title)
.join("', '")}'. Deleting this column will also delete the related Link column${columns.length > 1 ? 's' : ''}.`
}) */

const onDelete = async () => {
if (!column?.value) return

Expand Down Expand Up @@ -71,5 +96,8 @@ const onDelete = async () => {
</div>
</div>
</template>

<!-- disable for time being - internal discussion required -->
<!-- <template v-if="warningMsg" #warning>{{ warningMsg }}</template> -->
</GeneralDeleteModal>
</template>
2 changes: 1 addition & 1 deletion packages/nc-gui/components/smartsheet/header/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const isDeleteAllowed = computed(() => {
return column?.value && !column.value.system
})
const isDuplicateAllowed = computed(() => {
return column?.value && !column.value.system
return column?.value && !column.value.system && !column.value.meta?.custom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The verification process has successfully identified the implementation of the isDuplicateAllowed computed property in the Menu.vue and FieldMenu.vue components within the nc-gui package. The condition for isDuplicateAllowed is consistent across these components, as shown in the script output:

  • In Menu.vue, the condition is:
    return column?.value && !column.value.system && !column.value.meta?.custom
    
  • In FieldMenu.vue, the condition is slightly different:
    return column?.value && !column.value.system
    

This indicates that while the condition is implemented in both components, there is a variation in the FieldMenu.vue where the check for column.value.meta?.custom is not included.

Conclusion:

  • The new condition for isDuplicateAllowed is implemented in the identified Vue components.
  • There is a discrepancy in the implementation between Menu.vue and FieldMenu.vue which might be intentional or an oversight.

Action Points:

  • Confirm if the difference in conditions between Menu.vue and FieldMenu.vue is intentional.
  • If the discrepancy is not intended, align the condition in FieldMenu.vue with that in Menu.vue.
Analysis chain

Ensure the new condition for isDuplicateAllowed is correctly implemented.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the new condition for `isDuplicateAllowed` is correctly implemented across the system.

# Find files that use the `isDuplicateAllowed` computed property.
rg --files-with-matches --type vue $'isDuplicateAllowed' | while read file; do
  # Test: Search for the usage of the `isDuplicateAllowed` to validate the new condition. Expect: Matches.
  ast-grep --lang vue --pattern $'isDuplicateAllowed' "$file"
done

Length of output: 95



Script:

#!/bin/bash
# Description: Verify that the new condition for `isDuplicateAllowed` is correctly implemented across the system.

# Find Vue files and check for the usage of `isDuplicateAllowed`.
rg --files-with-matches --glob '*.vue' 'isDuplicateAllowed' | while read file; do
  # Test: Search for the usage of the `isDuplicateAllowed` to validate the new condition. Expect: Matches.
  ast-grep --lang vue --pattern $'isDuplicateAllowed' "$file"
done

Length of output: 522



Script:

#!/bin/bash
# Description: Verify that the new condition for `isDuplicateAllowed` is correctly implemented across the system.

# Find Vue files and check for the usage and context of `isDuplicateAllowed`.
rg --glob '*.vue' -C 3 'isDuplicateAllowed' 

Length of output: 2826

})
const isFilterSupported = computed(
() =>
Expand Down