Browse Source

fix(nc-gui): disabled rich text and ai prompt options from long text field if it is pv column

pull/9986/head
Ramesh Mane 2 days ago
parent
commit
1b564512cd
  1. 32
      packages/nc-gui/components/smartsheet/column/LongTextOptions.vue
  2. 7
      packages/nocodb-sdk/src/lib/UITypes.ts

32
packages/nc-gui/components/smartsheet/column/LongTextOptions.vue

@ -1,5 +1,5 @@
<script setup lang="ts">
import { isAIPromptCol, UITypes } from 'nocodb-sdk'
import { columnTypeName, isAIPromptCol, UITypes, UITypesName } from 'nocodb-sdk'
const props = defineProps<{
modelValue: any
@ -59,6 +59,12 @@ const isEnabledGenerateText = computed({
},
})
const isPvColumn = computed(() => {
if (!isEdit.value) return false
return !!column.value?.pv
})
const loadViewData = async () => {
if (!formattedData.value.length) {
await loadData(undefined, false)
@ -180,10 +186,16 @@ watch(isPreviewEnabled, handleDisableSubmitBtn, {
<template>
<div class="flex flex-col gap-4">
<a-form-item>
<NcTooltip :disabled="!isEnabledGenerateText">
<template #title> Rich text formatting is not supported when generate text using AI is enabled </template>
<NcTooltip :disabled="!(isEnabledGenerateText || (isPvColumn && !richMode))">
<template #title>
{{
isPvColumn && !richMode
? `${UITypesName.RichText} field cannot be a display value field`
: 'Rich text formatting is not supported when generate text using AI is enabled'
}}
</template>
<div class="flex items-center gap-1">
<NcSwitch v-model:checked="richMode" :disabled="isEnabledGenerateText">
<NcSwitch v-model:checked="richMode" :disabled="isEnabledGenerateText || (isPvColumn && !richMode)">
<div class="text-sm text-gray-800 select-none font-semibold">
{{ $t('labels.enableRichText') }}
</div>
@ -194,12 +206,18 @@ watch(isPreviewEnabled, handleDisableSubmitBtn, {
<div v-if="isPromptEnabled" class="relative">
<a-form-item class="flex items-center">
<NcTooltip :disabled="!richMode" class="flex items-center">
<template #title> Generate text using AI is not supported when rich text formatting is enabled </template>
<NcTooltip :disabled="!(richMode || (isPvColumn && !isEnabledGenerateText))" class="flex items-center">
<template #title>
{{
isPvColumn && !isEnabledGenerateText
? `${UITypesName.AIPrompt} field cannot be a display value field`
: 'Generate text using AI is not supported when rich text formatting is enabled'
}}</template
>
<NcSwitch
v-model:checked="isEnabledGenerateText"
:disabled="richMode"
:disabled="richMode || (isPvColumn && !isEnabledGenerateText)"
class="nc-ai-field-generate-text nc-ai-input"
@change="handleDisableSubmitBtn"
>

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

@ -94,7 +94,7 @@ export const UITypesName = {
AIPrompt: 'AI Prompt',
};
export const columnTypeName = (column: ColumnType) => {
export const columnTypeName = (column?: ColumnType) => {
if (!column) return '';
switch (column.uidt) {
@ -102,7 +102,10 @@ export const columnTypeName = (column: ColumnType) => {
if (ncParseProp(column.meta)?.richMode) {
return UITypesName.RichText;
}
//Todo: prevent AI Prompt field once it get merged in develop
if (ncParseProp(column.meta)[LongTextAiMetaProp]) {
return UITypesName.AIPrompt;
}
return UITypesName[column.uidt];
}

Loading…
Cancel
Save