Browse Source

fix(nc-gui): don't allow AI prompt field to set as pv column

pull/9986/head
Ramesh Mane 2 days ago
parent
commit
457054ed47
  1. 20
      packages/nocodb-sdk/src/lib/UITypes.ts
  2. 2
      packages/nocodb-sdk/src/lib/helperFunctions.ts

20
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(<UITypes>(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;
}

2
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;
}

Loading…
Cancel
Save