Browse Source

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

pull/7478/head
Ramesh Mane 7 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> <script lang="ts" setup>
import type { ColumnReqType, ColumnType } from 'nocodb-sdk' 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 { import {
IsFormInj, IsFormInj,
IsKanbanInj, IsKanbanInj,
@ -172,7 +172,7 @@ onMounted(() => {
if (formState.value.pk) { if (formState.value.pk) {
message.info(t('msg.info.editingPKnotSupported')) message.info(t('msg.info.editingPKnotSupported'))
emit('cancel') emit('cancel')
} else if (isSystemColumn(formState.value)) { } else if (isSystemColumn(formState.value) && !isSelfReferencingTableColumn(formState.value)) {
message.info(t('msg.info.editingSystemKeyNotSupported')) message.info(t('msg.info.editingSystemKeyNotSupported'))
emit('cancel') 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.pk && col.meta && col.meta.ag) ||
col.system); 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 => { const extractRolesObj = (roles: RolesType): RolesObj => {
if (!roles) return null; if (!roles) return null;
@ -89,6 +100,7 @@ export {
getSystemColumnsIds, getSystemColumnsIds,
getSystemColumns, getSystemColumns,
isSystemColumn, isSystemColumn,
isSelfReferencingTableColumn,
extractRolesObj, extractRolesObj,
stringifyRolesObj, stringifyRolesObj,
getAvailableRollupForUiType, getAvailableRollupForUiType,

Loading…
Cancel
Save