refactor: table column field provider optimize (#2312)

This commit is contained in:
katherinehhh 2023-07-25 09:42:59 +08:00 committed by GitHub
parent 063d7ca693
commit d8befa75c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,10 +14,23 @@ export const ColumnFieldProvider = observer(
return buf;
}, null);
const collectionField = fieldSchema && getCollectionJoinField(fieldSchema['x-collection-field']);
if (fieldSchema && record?.__collection && ['select', 'multipleSelect'].includes(collectionField?.interface)) {
if (
fieldSchema &&
record?.__collection &&
collectionField &&
['select', 'multipleSelect'].includes(collectionField.interface)
) {
const fieldName = `${record.__collection}.${fieldSchema.name}`;
schema.properties[fieldSchema.name]['x-collection-field'] = fieldName;
return <RecursionField basePath={basePath} schema={schema} onlyRenderProperties />;
const newSchema = {
...schema.toJSON(),
properties: {
[fieldSchema.name]: {
...fieldSchema.toJSON(),
'x-collection-field': fieldName,
},
},
};
return <RecursionField basePath={basePath} schema={newSchema} onlyRenderProperties />;
}
return props.children;
},