fix: error when overriding sorting field (#4752)

This commit is contained in:
Katherine 2024-06-26 13:18:07 +08:00 committed by GitHub
parent 0c7d697774
commit 9669d56d84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -113,7 +113,7 @@ const getIsOverriding = (currentFields, record) => {
export const OverridingFieldAction = (props) => { export const OverridingFieldAction = (props) => {
const { scope, getContainer, item: record, parentItem: parentRecord, children, currentCollection } = props; const { scope, getContainer, item: record, parentItem: parentRecord, children, currentCollection } = props;
const { target, through } = record; const { target, through } = record;
const { getInterface, getCurrentCollectionFields, getChildrenCollections, collections } = const { getInterface, getCollection, getCurrentCollectionFields, getChildrenCollections, collections } =
useCollectionManager_deprecated(); useCollectionManager_deprecated();
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [schema, setSchema] = useState({}); const [schema, setSchema] = useState({});
@ -171,6 +171,23 @@ export const OverridingFieldAction = (props) => {
}, },
}; };
}; };
const scopeKeyOptions = useMemo(() => {
return (
record?.fields ||
getCollection(record.collectionName)
?.options.fields.filter((v) => {
return ['string', 'bigInt', 'integer'].includes(v.type);
})
.map((k) => {
return {
value: k.name,
label: compile(k.uiSchema?.title),
};
})
);
}, [record.name]);
return ( return (
<RecordProvider record={{ ...record, collectionName: parentRecord.name }} parent={parentRecord}> <RecordProvider record={{ ...record, collectionName: parentRecord.name }} parent={parentRecord}>
<ActionContextProvider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
@ -221,6 +238,7 @@ export const OverridingFieldAction = (props) => {
isOverride: true, isOverride: true,
targetScope: { target: getFilterCollections(target), through: getFilterCollections(through) }, targetScope: { target: getFilterCollections(target), through: getFilterCollections(through) },
collections: currentCollections, collections: currentCollections,
scopeKeyOptions,
...scope, ...scope,
}} }}
/> />