Skip to content

[Backport] Move buttons definition to separate file #15862

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
Jun 14, 2018
Merged

[Backport] Move buttons definition to separate file #15862

merged 6 commits into from
Jun 14, 2018

Conversation

RahulKachhadia
Copy link
Member

Original Pull Request

#15194
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

Hi @rahul-kachhadiya. Thank you for your contribution.
Changes from your Pull Request will be available with the upcoming 2.1.15 release.

@RahulKachhadia RahulKachhadia deleted the 2.1-develop-PR-port-15194 branch June 19, 2018 08:45
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.

4 participants