There is no way to specifiy includes for included admin
Opened this issue · 0 comments
X-Coder264 commented
export default {
resourceName: 'orders',
includedRelationships: {
index: ['client', 'school'],
edit: ['client', 'school', 'orderPackageHistory', 'orderPackageHistory.package', 'orderPackages', 'orderPackages.package']
},
setupEdit({edit, method}) {
this.addToIndexControl().addSaveControl();
edit.addField('IncludedAdminFormElement', {
label: 'Order packages',
name: 'orderPackages',
layoutReference: 'mainRegion',
setupEdit: ({editIncluded, method, resourceModel}) => {
editIncluded.addField('ExternalAdminFormElement', {
label: 'Package',
name: 'package',
mapCaptionTo: 'name',
relation: {type: 'hasOne', resourceName: 'packages'},
readOnly: method === 'edit'
});
},
relation: {type: 'hasMany', resourceName: 'orderPackages', reverseRelationName: 'order'}
});
}
}
};
When creating an order in my case which consists of order packages the package name is not populated (because the POST create request for the order package does not add the package
include). Refreshing the page populates that data (because of the edit resource includes which are specified at the top).
Ideally, the included admin would read the already specified includes at the top and apply only the includes that are related to the included admin resource for the POST and PATCH that it does, e.g.
POST /api/v1/orderPackages?include=package
instead of
POST /api/v1/orderPackages