Browse Source

Merge pull request #3498 from nocodb/fix/3485-edit-pk

fix: block attempts to edit primary key column
pull/3499/head
Raju Udava 2 years ago committed by GitHub
parent
commit
e4ff610734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue

16
packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue

@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { UITypes, isVirtualCol } from 'nocodb-sdk' import { UITypes, isVirtualCol } from 'nocodb-sdk'
import { message } from 'ant-design-vue'
import { computed, inject, useMetas, watchEffect } from '#imports' import { computed, inject, useMetas, watchEffect } from '#imports'
import { MetaInj, ReloadViewDataHookInj } from '~/context' import { MetaInj, ReloadViewDataHookInj } from '~/context'
import { uiTypes } from '~/utils/columnUtils' import { uiTypes } from '~/utils/columnUtils'
@ -9,17 +10,19 @@ import MdiIdentifierIcon from '~icons/mdi/identifier'
const emit = defineEmits(['submit', 'cancel']) const emit = defineEmits(['submit', 'cancel'])
const meta = inject(MetaInj)
const { formState, generateNewColumnMeta, addOrUpdate, onAlter, onUidtOrIdTypeChange, validateInfos, isEdit } = const { formState, generateNewColumnMeta, addOrUpdate, onAlter, onUidtOrIdTypeChange, validateInfos, isEdit } =
useColumnCreateStoreOrThrow() useColumnCreateStoreOrThrow()
const { getMeta } = useMetas()
const { t } = useI18n()
const meta = inject(MetaInj)
const reloadDataTrigger = inject(ReloadViewDataHookInj) const reloadDataTrigger = inject(ReloadViewDataHookInj)
const advancedOptions = ref(false) const advancedOptions = ref(false)
const { getMeta } = useMetas()
const columnToValidate = [UITypes.Email, UITypes.URL, UITypes.PhoneNumber] const columnToValidate = [UITypes.Email, UITypes.URL, UITypes.PhoneNumber]
const onlyNameUpdateOnEditColumns = [UITypes.LinkToAnotherRecord, UITypes.Lookup, UITypes.Rollup] const onlyNameUpdateOnEditColumns = [UITypes.LinkToAnotherRecord, UITypes.Lookup, UITypes.Rollup]
@ -70,6 +73,11 @@ watchEffect(() => {
onMounted(() => { onMounted(() => {
if (isEdit.value === false) { if (isEdit.value === false) {
generateNewColumnMeta() generateNewColumnMeta()
} else {
if (formState.value.pk) {
message.info(t('msg.info.editingPKnotSupported'))
emit('cancel')
}
} }
// for cases like formula // for cases like formula

Loading…
Cancel
Save