Skip to content

There is no way to specifiy includes for included admin #19

@X-Coder264

Description

@X-Coder264
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions