Skip to content

Move buttons definition to separate file #15194

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

Merged
merged 6 commits into from
May 18, 2018
Merged

Move buttons definition to separate file #15194

merged 6 commits into from
May 18, 2018

Conversation

jissereitsma
Copy link
Contributor

When trying to add new buttons with new actions (besides reset, save and saveAndContinue) to a UiComponent form in the backend, it is needed to extend upon at least 2 files: Magento_Ui/js/form/adapter and Magento_Ui/js/form/form. The second file is easily extendable using mixins, but the first one is not: Mainly because the buttons definition is based on a local variable. This PR fixes this by moving the buttons definition in a separate file.

Description

This PR adds a new file buttons.js that is called for in adapter so that someone could create a mixin like follows:

RequireJS configuration:

var config = {
    config: {
        mixins: {
            'Magento_Ui/js/form/form': {
                'Foo_Bar/js/form/form-mixin': true
            }
        }
    }
};

And in Foo_Bar/js/form/form-mixin:

define([
    'underscore'
], function (_) {
    'use strict';

    var mixin = {
        'foobar': '#foobar'
    };

    return function (target) {
        return _.extend(target, mixin);
    };
});

Unfortunately, this PR does not deal with how to use foobar in the end, which is hugely complex.

Manual testing scenarios

  1. Apply the PR
  2. Confirm that form buttons like Save and Save And Continue are still working in the backend

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

@jissereitsma thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@VladimirZaets
Copy link
Contributor

Hi @jissereitsma. Thank you for collaboration. Please check the tests that are failed on the Travis.

@VladimirZaets
Copy link
Contributor

@jissereitsma thanks.

@jissereitsma
Copy link
Contributor Author

@VladimirZaets Sorry for the delays and the coding errors: It worked perfectly in my own development environment, but I didn't carefully setup my GitHub clone to copy the right changes: This is fixed now and the checks have passed. Let me know if you need anything else.

@magento-engcom-team
Copy link
Contributor

Hi @jissereitsma. Thank you for your contribution.
Changes from your Pull Request will be available with the upcoming 2.2.5 release.

Please, consider porting this solution across release lines.
You may use Porting tool to port commits automatically.

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

Successfully merging this pull request may close these issues.

3 participants