fix: association field should support json field as title field (#3129)
This commit is contained in:
parent
c1c91095b8
commit
bdf49cd38a
@ -24,6 +24,9 @@ const toValue = (value, placeholder) => {
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
function isObject(value) {
|
||||||
|
return typeof value === 'object' && value !== null;
|
||||||
|
}
|
||||||
export const ReadPrettyInternalViewer: React.FC = observer(
|
export const ReadPrettyInternalViewer: React.FC = observer(
|
||||||
(props: any) => {
|
(props: any) => {
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
@ -45,11 +48,14 @@ export const ReadPrettyInternalViewer: React.FC = observer(
|
|||||||
const ellipsisWithTooltipRef = useRef<IEllipsisWithTooltipRef>();
|
const ellipsisWithTooltipRef = useRef<IEllipsisWithTooltipRef>();
|
||||||
const renderRecords = () =>
|
const renderRecords = () =>
|
||||||
toArr(props.value).map((record, index, arr) => {
|
toArr(props.value).map((record, index, arr) => {
|
||||||
|
const value = record?.[fieldNames?.label || 'label'];
|
||||||
const label = isTreeCollection
|
const label = isTreeCollection
|
||||||
? transformNestedData(record)
|
? transformNestedData(record)
|
||||||
.map((o) => o?.[fieldNames?.label || 'label'])
|
.map((o) => o?.[fieldNames?.label || 'label'])
|
||||||
.join(' / ')
|
.join(' / ')
|
||||||
: record?.[fieldNames?.label || 'label'];
|
: isObject(value)
|
||||||
|
? JSON.stringify(value)
|
||||||
|
: value;
|
||||||
const val = toValue(compile(label), 'N/A');
|
const val = toValue(compile(label), 'N/A');
|
||||||
const labelUiSchema = useLabelUiSchema(
|
const labelUiSchema = useLabelUiSchema(
|
||||||
record?.__collection || collectionField?.target,
|
record?.__collection || collectionField?.target,
|
||||||
|
Loading…
Reference in New Issue
Block a user