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 { ColumnReqType, ColumnType, TableType } from './Api';
import { FormulaDataTypes } from './formulaHelpers'; import { FormulaDataTypes } from './formulaHelpers';
import { LongTextAiMetaProp, RelationTypes } from '~/lib/globals'; import { LongTextAiMetaProp, RelationTypes } from '~/lib/globals';
import { parseHelper } from './helperFunctions'; import { parseHelper, ncParseProp } from './helperFunctions';
import { ncParseProp } from './helperFunctions';
enum UITypes { enum UITypes {
ID = 'ID', ID = 'ID',
@ -217,12 +216,11 @@ export function isVirtualCol(
].includes(<UITypes>(typeof col === 'object' ? col?.uidt : col)); ].includes(<UITypes>(typeof col === 'object' ? col?.uidt : col));
} }
export function isAIPromptCol( export function isAIPromptCol(col: ColumnReqType | ColumnType) {
col: return (
| ColumnReqType col.uidt === UITypes.LongText &&
| ColumnType parseHelper((col as any)?.meta)?.[LongTextAiMetaProp]
) { );
return col.uidt === UITypes.LongText && parseHelper((col as any)?.meta)?.[LongTextAiMetaProp];
} }
export function isCreatedOrLastModifiedTimeCol( export function isCreatedOrLastModifiedTimeCol(
@ -381,10 +379,12 @@ export const isSupportedDisplayValueColumn = (column: ColumnType) => {
return true; return true;
} }
case UITypes.LongText: { case UITypes.LongText: {
if (ncParseProp(column.meta)?.richMode) { if (
ncParseProp(column.meta)?.richMode ||
ncParseProp(column.meta)[LongTextAiMetaProp]
) {
return false; return false;
} }
//Todo: prevent AI Prompt field once it get merged in develop
return true; 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 { export function stringifyHelper(v: any): string {
try { try {
return JSON.stringify(v); return typeof v === 'string' ? v : JSON.stringify(v);
} catch { } catch {
return v; return v;
} }

Loading…
Cancel
Save