fix: association data params missing appends (#3103)
* fix: association data params missing appends * refactor: code improve
This commit is contained in:
parent
f5dc8cebf8
commit
0cf045d142
@ -307,10 +307,7 @@ export const BlockProvider = (props: {
|
|||||||
const resource = useResource(props);
|
const resource = useResource(props);
|
||||||
const { appends, updateAssociationValues } = useAssociationNames();
|
const { appends, updateAssociationValues } = useAssociationNames();
|
||||||
const params = useMemo(() => {
|
const params = useMemo(() => {
|
||||||
if (!props.params) {
|
if (!props.params?.['appends']) {
|
||||||
return props.params;
|
|
||||||
}
|
|
||||||
if (!props.params['appends']) {
|
|
||||||
return { ...props.params, appends };
|
return { ...props.params, appends };
|
||||||
}
|
}
|
||||||
return { ...props.params };
|
return { ...props.params };
|
||||||
|
@ -5,6 +5,9 @@ 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) => {
|
||||||
@ -70,7 +73,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: JSON.stringify(content),
|
default: isObject(content) ? JSON.stringify(content) : content,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@ const ReadPretty = (props) => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<EllipsisWithTooltip ellipsis={true}>
|
<EllipsisWithTooltip ellipsis={true}>
|
||||||
{value?.map((item) => (Array.isArray(item) ? `(${item.join(',')})` : item)).join(',')}
|
{value?.map?.((item) => (Array.isArray(item) ? `(${item.join(',')})` : item)).join(',')}
|
||||||
</EllipsisWithTooltip>
|
</EllipsisWithTooltip>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user