Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
X-Coder264 opened this issue Apr 21, 2021 · 0 comments
Open

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

X-Coder264 opened this issue Apr 21, 2021 · 0 comments

Comments

@X-Coder264
Copy link

X-Coder264 commented Apr 21, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant