Browse Source

fix(nc-gui): disable set displaly value option from field context menu

pull/9986/head
Ramesh Mane 3 days ago
parent
commit
f6c1506cb7
  1. 38
      packages/nc-gui/components/smartsheet/header/Menu.vue
  2. 9
      packages/nc-gui/components/smartsheet/header/UpdateDisplayValue.vue
  3. 28
      packages/nocodb-sdk/src/lib/UITypes.ts
  4. 1
      packages/nocodb-sdk/src/lib/index.ts

38
packages/nc-gui/components/smartsheet/header/Menu.vue

@ -1,5 +1,12 @@
<script lang="ts" setup>
import { type ColumnReqType, type ColumnType, partialUpdateAllowedTypes, readonlyMetaAllowedTypes } from 'nocodb-sdk'
import {
type ColumnReqType,
type ColumnType,
columnTypeName,
isVirtualCol,
partialUpdateAllowedTypes,
readonlyMetaAllowedTypes,
} from 'nocodb-sdk'
import { PlanLimitTypes, RelationTypes, UITypes, isLinksOrLTAR, isSystemColumn, isSupportedDisplayValueColumn } from 'nocodb-sdk'
import { SmartsheetStoreEvents, isColumnInvalid } from '#imports'
@ -578,16 +585,25 @@ const onDeleteColumn = () => {
{{ isHiddenCol ? $t('general.showField') : $t('general.hideField') }}
</div>
</NcMenuItem>
<NcMenuItem v-if="column && isSupportedDisplayValueColumn(column) && !column?.pv && !isHiddenCol" @click="setAsDisplayValue">
<div class="nc-column-set-primary nc-header-menu-item item">
<GeneralLoader v-if="isLoading === 'setDisplay'" size="regular" />
<GeneralIcon v-else icon="star" class="text-gray-500 !w-4.25 !h-4.25" />
<!-- todo : tooltip -->
<!-- Set as Display value -->
{{ $t('activity.setDisplay') }}
</div>
</NcMenuItem>
<NcTooltip
v-if="column && !column?.pv && !isHiddenCol && (column.uidt === UITypes.Formula || !isVirtualCol(column))"
:disabled="isSupportedDisplayValueColumn(column)"
>
<template #title>
{{ `${columnTypeName(column)} field cannot be a display value field` }}
</template>
<NcMenuItem @click="setAsDisplayValue" :disabled="!isSupportedDisplayValueColumn(column)">
<div class="nc-column-set-primary nc-header-menu-item item">
<GeneralLoader v-if="isLoading === 'setDisplay'" size="regular" />
<GeneralIcon v-else icon="star" class="text-gray-500 !w-4.25 !h-4.25" />
<!-- todo : tooltip -->
<!-- Set as Display value -->
{{ $t('activity.setDisplay') }}
</div>
</NcMenuItem>
</NcTooltip>
<template v-if="!isExpandedForm">
<a-divider v-if="!isLinksOrLTAR(column) || column.colOptions.type !== RelationTypes.BELONGS_TO" class="!my-0" />

9
packages/nc-gui/components/smartsheet/header/UpdateDisplayValue.vue

@ -1,5 +1,5 @@
<script setup lang="ts">
import { type ColumnType, isSupportedDisplayValueColumn, isSystemColumn, isVirtualCol, UITypes, UITypesName } from 'nocodb-sdk'
import { type ColumnType, columnTypeName, isSupportedDisplayValueColumn, isSystemColumn, isVirtualCol } from 'nocodb-sdk'
interface Props {
column: ColumnType
@ -37,9 +37,10 @@ const filteredColumns = computed(() => {
title: f.title,
id: f.fk_column_id,
disabled: !isSupportedDisplayValueColumn(column),
ncItemTooltip: !isSupportedDisplayValueColumn(column)
? `${column?.uidt ? UITypesName[column.uidt as UITypes] : 'This'} field cannot be a display value field`
: '',
ncItemTooltip:
!isSupportedDisplayValueColumn(column) && columnTypeName(column)
? `${columnTypeName(column)} field cannot be a display value field`
: '',
column: column,
}
})

28
packages/nocodb-sdk/src/lib/UITypes.ts

@ -95,6 +95,34 @@ export const UITypesName = {
AIPrompt: 'AI Prompt',
};
export const columnTypeName = (column: ColumnType) => {
if (!column) return '';
switch (column.uidt) {
case UITypes.LongText: {
if (ncParseProp(column.meta)?.richMode) {
return UITypesName.RichText;
}
//Todo: prevent AI Prompt field once it get merged in develop
return UITypesName[column.uidt];
}
case UITypes.Button: {
if (
column.uidt === UITypes.Button &&
(column?.colOptions as any)?.type === 'ai'
) {
return UITypesName.AIButton;
}
return UITypesName[column.uidt];
}
default: {
return column.uidt ? UITypesName[column.uidt] : '';
}
}
};
export const FieldNameFromUITypes: Record<UITypes, string> = {
[UITypes.ID]: 'ID',
[UITypes.LinkToAnotherRecord]: '{TableName}',

1
packages/nocodb-sdk/src/lib/index.ts

@ -25,6 +25,7 @@ export {
readonlyMetaAllowedTypes,
partialUpdateAllowedTypes,
isSupportedDisplayValueColumn,
columnTypeName,
} from '~/lib/UITypes';
export { default as CustomAPI, FileType } from '~/lib/CustomAPI';
export { default as TemplateGenerator } from '~/lib/TemplateGenerator';

Loading…
Cancel
Save