fix: appends

This commit is contained in:
chenos 2022-03-12 00:38:11 +08:00
parent db26c64aa2
commit 627e2a9f4c

View File

@ -28,6 +28,7 @@ const CollectionResourceActionProvider = (props) => {
if (actionName === 'get') { if (actionName === 'get') {
others['filterByTk'] = record[collection.targetKey || collection.filterTargetKey || 'id']; others['filterByTk'] = record[collection.targetKey || collection.filterTargetKey || 'id'];
} }
const appends = request?.params?.appends || [];
const service = useRequest( const service = useRequest(
{ {
...request, ...request,
@ -36,7 +37,7 @@ const CollectionResourceActionProvider = (props) => {
...request?.params, ...request?.params,
appends: [ appends: [
...collection?.fields?.filter?.((field) => field.target).map((field) => field.name), ...collection?.fields?.filter?.((field) => field.target).map((field) => field.name),
...request?.params?.appends, ...appends,
], ],
sort: dragSort ? [collection.sortable === true ? 'sort' : collection.sortable] : request?.params?.sort, sort: dragSort ? [collection.sortable === true ? 'sort' : collection.sortable] : request?.params?.sort,
}, },
@ -58,6 +59,7 @@ const AssociationResourceActionProvider = (props) => {
const api = useAPIClient(); const api = useAPIClient();
const record = useRecord(); const record = useRecord();
const resourceOf = record[association.sourceKey]; const resourceOf = record[association.sourceKey];
const appends = request?.params?.appends || [];
const service = useRequest( const service = useRequest(
{ {
resourceOf, resourceOf,
@ -66,7 +68,7 @@ const AssociationResourceActionProvider = (props) => {
...request?.params, ...request?.params,
appends: [ appends: [
...collection?.fields?.filter?.((field) => field.target).map((field) => field.name), ...collection?.fields?.filter?.((field) => field.target).map((field) => field.name),
...request?.params?.appends, ...appends,
], ],
}, },
}, },