Browse Source

fix: allow renaming of belongs to column nocodb/nocodb#7441

pull/7478/head
Ramesh Mane 5 months ago
parent
commit
a1969be7d0
  1. 4
      packages/nc-gui/components/smartsheet/column/EditOrAdd.vue
  2. 12
      packages/nocodb-sdk/src/lib/helperFunctions.ts

4
packages/nc-gui/components/smartsheet/column/EditOrAdd.vue

@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { ColumnReqType, ColumnType } from 'nocodb-sdk'
import { UITypes, isLinksOrLTAR, isSystemColumn, isVirtualCol } from 'nocodb-sdk'
import { UITypes, isLinksOrLTAR, isSystemColumn, isVirtualCol, isSelfReferencingTableColumn } from 'nocodb-sdk'
import {
IsFormInj,
IsKanbanInj,
@ -172,7 +172,7 @@ onMounted(() => {
if (formState.value.pk) {
message.info(t('msg.info.editingPKnotSupported'))
emit('cancel')
} else if (isSystemColumn(formState.value)) {
} else if (isSystemColumn(formState.value) && !isSelfReferencingTableColumn(formState.value)) {
message.info(t('msg.info.editingSystemKeyNotSupported'))
emit('cancel')
}

12
packages/nocodb-sdk/src/lib/helperFunctions.ts

@ -22,6 +22,17 @@ const isSystemColumn = (col): boolean =>
(col.pk && col.meta && col.meta.ag) ||
col.system);
const isSelfReferencingTableColumn = (col): boolean => {
return (
col &&
(col.uidt === UITypes.Links || col.uidt === UITypes.LinkToAnotherRecord) &&
(col?.fk_model_id || col?.colOptions?.fk_model_id) &&
col?.colOptions?.fk_related_model_id &&
(col?.fk_model_id || col?.colOptions?.fk_model_id) ===
col.colOptions.fk_related_model_id
);
};
const extractRolesObj = (roles: RolesType): RolesObj => {
if (!roles) return null;
@ -89,6 +100,7 @@ export {
getSystemColumnsIds,
getSystemColumns,
isSystemColumn,
isSelfReferencingTableColumn,
extractRolesObj,
stringifyRolesObj,
getAvailableRollupForUiType,

Loading…
Cancel
Save