fix: association data params missing appends (#3103)

* fix: association data params missing appends

* refactor: code improve
This commit is contained in:
katherinehhh 2023-11-28 11:12:42 +08:00 committed by GitHub
parent f5dc8cebf8
commit 0cf045d142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -307,10 +307,7 @@ export const BlockProvider = (props: {
const resource = useResource(props);
const { appends, updateAssociationValues } = useAssociationNames();
const params = useMemo(() => {
if (!props.params) {
return props.params;
}
if (!props.params['appends']) {
if (!props.params?.['appends']) {
return { ...props.params, appends };
}
return { ...props.params };

View File

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

View File

@ -16,7 +16,7 @@ const ReadPretty = (props) => {
return (
<div>
<EllipsisWithTooltip ellipsis={true}>
{value?.map((item) => (Array.isArray(item) ? `(${item.join(',')})` : item)).join(',')}
{value?.map?.((item) => (Array.isArray(item) ? `(${item.join(',')})` : item)).join(',')}
</EllipsisWithTooltip>
</div>
);