fix: association field should support json field as title field (#3129)

This commit is contained in:
katherinehhh 2023-12-03 19:14:33 +08:00 committed by GitHub
parent c1c91095b8
commit bdf49cd38a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,9 @@ const toValue = (value, placeholder) => {
}
return value;
};
function isObject(value) {
return typeof value === 'object' && value !== null;
}
export const ReadPrettyInternalViewer: React.FC = observer(
(props: any) => {
const fieldSchema = useFieldSchema();
@ -45,11 +48,14 @@ export const ReadPrettyInternalViewer: React.FC = observer(
const ellipsisWithTooltipRef = useRef<IEllipsisWithTooltipRef>();
const renderRecords = () =>
toArr(props.value).map((record, index, arr) => {
const value = record?.[fieldNames?.label || 'label'];
const label = isTreeCollection
? transformNestedData(record)
.map((o) => o?.[fieldNames?.label || 'label'])
.join(' / ')
: record?.[fieldNames?.label || 'label'];
: isObject(value)
? JSON.stringify(value)
: value;
const val = toValue(compile(label), 'N/A');
const labelUiSchema = useLabelUiSchema(
record?.__collection || collectionField?.target,