From 457054ed4798a540e56f15b4895ac70ad85b5aa3 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Tue, 10 Dec 2024 07:57:59 +0000 Subject: [PATCH] fix(nc-gui): don't allow AI prompt field to set as pv column --- packages/nocodb-sdk/src/lib/UITypes.ts | 20 +++++++++---------- .../nocodb-sdk/src/lib/helperFunctions.ts | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/nocodb-sdk/src/lib/UITypes.ts b/packages/nocodb-sdk/src/lib/UITypes.ts index ed9c93e567..7c1cee69a8 100644 --- a/packages/nocodb-sdk/src/lib/UITypes.ts +++ b/packages/nocodb-sdk/src/lib/UITypes.ts @@ -1,8 +1,7 @@ import { ColumnReqType, ColumnType, TableType } from './Api'; import { FormulaDataTypes } from './formulaHelpers'; import { LongTextAiMetaProp, RelationTypes } from '~/lib/globals'; -import { parseHelper } from './helperFunctions'; -import { ncParseProp } from './helperFunctions'; +import { parseHelper, ncParseProp } from './helperFunctions'; enum UITypes { ID = 'ID', @@ -217,12 +216,11 @@ export function isVirtualCol( ].includes((typeof col === 'object' ? col?.uidt : col)); } -export function isAIPromptCol( - col: - | ColumnReqType - | ColumnType -) { - return col.uidt === UITypes.LongText && parseHelper((col as any)?.meta)?.[LongTextAiMetaProp]; +export function isAIPromptCol(col: ColumnReqType | ColumnType) { + return ( + col.uidt === UITypes.LongText && + parseHelper((col as any)?.meta)?.[LongTextAiMetaProp] + ); } export function isCreatedOrLastModifiedTimeCol( @@ -381,10 +379,12 @@ export const isSupportedDisplayValueColumn = (column: ColumnType) => { return true; } case UITypes.LongText: { - if (ncParseProp(column.meta)?.richMode) { + if ( + ncParseProp(column.meta)?.richMode || + ncParseProp(column.meta)[LongTextAiMetaProp] + ) { return false; } - //Todo: prevent AI Prompt field once it get merged in develop return true; } diff --git a/packages/nocodb-sdk/src/lib/helperFunctions.ts b/packages/nocodb-sdk/src/lib/helperFunctions.ts index e5a7e3c55c..32567926ff 100644 --- a/packages/nocodb-sdk/src/lib/helperFunctions.ts +++ b/packages/nocodb-sdk/src/lib/helperFunctions.ts @@ -256,7 +256,7 @@ export function parseHelper(v: any): any { export function stringifyHelper(v: any): string { try { - return JSON.stringify(v); + return typeof v === 'string' ? v : JSON.stringify(v); } catch { return v; }