-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
base: develop
Are you sure you want to change the base?
Changes from all commits
cad8a12
8b8a1c8
64051df
fb87624
a610878
2de9a98
c741e5a
9604954
4b31c12
ae3aa98
765aa37
9ca045e
a829bba
60fbc06
26c56f9
fb7d5f9
ac7caa8
1407fdc
0982e41
64a0d24
57f9087
03e84e1
4fb1f9f
dfbe7a2
2f19418
46e509d
ed92052
5df67af
9e284f1
94411f4
5526260
eb0de18
6441ca3
73f1cf2
9ef4913
73c9843
a181092
bce7d1c
b6387ef
86dcb48
5bf8412
25379fb
b07fe5b
36b962f
090ef60
7fbbb0d
2418db2
76d49f4
bbf71df
9a763ee
1f58c6d
199322f
d5ecf5c
f054879
d3aa932
fb5e4e0
878ca41
e13413a
464cc4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -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
+73
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification The refactoring of the toggle logic in
Analysis chainEnsure the refactored toggle logic is implemented as suggested. Scripts ExecutedThe 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" | ||
|
@@ -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')"> | ||
|
@@ -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 |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
This indicates that while the condition is implemented in both components, there is a variation in the Conclusion:
Action Points:
Analysis chainEnsure the new condition for Scripts ExecutedThe 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( | ||
() => | ||
|
There was a problem hiding this comment.
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.
This refactoring combines the logic of
onCustomSwitchToggle
andhandleShowAdvanceOptions
into a single method, reducing redundancy and improving readability.Committable suggestion