All files / web/bundles/pimui/js/controller/attribute-group edit.js

92.31% Statements 12/13
50% Branches 1/2
100% Functions 5/5
92.31% Lines 12/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                  13x                       13x         13x   13x       13x         13x   13x 1x   13x   13x   13x   13x              
'use strict';
 
/**
 * Attribute group edit controller
 *
 * @author    Julien Sanchez <julien@akeneo.com>
 * @copyright 2017 Akeneo SAS (http://www.akeneo.com)
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
define(
    [
        'underscore',
        'oro/translator',
        'pim/controller/front',
        'pim/form-builder',
        'pim/fetcher-registry',
        'pim/user-context',
        'pim/dialog',
        'pim/page-title'
    ],
    function (_, __, BaseController, FormBuilder, FetcherRegistry, UserContext, Dialog, PageTitle) {
        return BaseController.extend({
            /**
             * {@inheritdoc}
             */
            renderForm: function (route) {
                return FetcherRegistry.getFetcher('attribute-group').fetch(route.params.identifier, {cached: false})
                    .then((attributeGroup) => {
                        Iif (!this.active) {
                            return;
                        }
 
                        PageTitle.set({
                            'group.label':
                            _.escape(attributeGroup.labels[UserContext.get('catalogLocale')])
                        });
 
                        return FormBuilder.build('pim-attribute-group-edit-form')
                            .then((form) => {
                                this.on('pim:controller:can-leave', function (event) {
                                    form.trigger('pim_enrich:form:can-leave', event);
                                });
                                form.setData(attributeGroup);
 
                                form.trigger('pim_enrich:form:entity:post_fetch', attributeGroup);
 
                                form.setElement(this.$el).render();
 
                                return form;
                            });
                    });
            }
        });
    }
);