refactor: view collection support json field (#3125)

This commit is contained in:
katherinehhh 2023-12-01 15:36:32 +08:00 committed by GitHub
parent 6fc644d506
commit a436b59268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -206,6 +206,9 @@ export const AddFieldAction = (props) => {
if (v.value === 'id') { if (v.value === 'id') {
return typeof record['autoGenId'] === 'boolean' ? record['autoGenId'] : true; return typeof record['autoGenId'] === 'boolean' ? record['autoGenId'] : true;
} else if (v.value === 'tableoid') { } else if (v.value === 'tableoid') {
if (include?.length) {
return include.includes(v.value);
}
return database?.dialect === 'postgres'; return database?.dialect === 'postgres';
} else { } else {
return typeof record[v.value] === 'boolean' ? record[v.value] : true; return typeof record[v.value] === 'boolean' ? record[v.value] : true;

View File

@ -5,9 +5,6 @@ import { useTranslation } from 'react-i18next';
import { EllipsisWithTooltip, useCompile } from '../../../'; import { EllipsisWithTooltip, useCompile } from '../../../';
import { useAPIClient } from '../../../api-client'; import { useAPIClient } from '../../../api-client';
import { useCollectionManager } from '../../hooks/useCollectionManager'; import { useCollectionManager } from '../../hooks/useCollectionManager';
function isObject(value) {
return Object.prototype.toString.call(value) === '[object Object]';
}
const mapFields = ['lineString', 'point', 'circle', 'polygon']; const mapFields = ['lineString', 'point', 'circle', 'polygon'];
export const PreviewTable = (props) => { export const PreviewTable = (props) => {
@ -73,7 +70,7 @@ export const PreviewTable = (props) => {
'x-component': schema && fieldSource ? 'CollectionField' : 'Input', 'x-component': schema && fieldSource ? 'CollectionField' : 'Input',
'x-read-pretty': true, 'x-read-pretty': true,
'x-collection-field': fieldSource?.join('.'), 'x-collection-field': fieldSource?.join('.'),
default: isObject(content) ? JSON.stringify(content) : content, default: item.interface === 'json' ? JSON.stringify(content) : content,
}, },
}, },
}; };