All files / web/bundles/pimui/js/controller group-type.js

92.86% Statements 13/14
50% Branches 1/2
100% Functions 5/5
92.86% Lines 13/14

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    5x                         5x         5x   5x       5x               5x   5x   5x 1x   5x 5x 5x   5x              
'use strict';
 
define(
    [
        'underscore',
        'oro/translator',
        'pim/controller/front',
        'pim/form-builder',
        'pim/fetcher-registry',
        'pim/user-context',
        'pim/dialog',
        'pim/page-title',
        'pim/i18n'
    ],
    function (_, __, BaseController, FormBuilder, FetcherRegistry, UserContext, Dialog, PageTitle, i18n) {
        return BaseController.extend({
            /**
             * {@inheritdoc}
             */
            renderForm: function (route) {
                return FetcherRegistry.getFetcher('group-type').fetch(route.params.code, {cached: false})
                    .then((groupType) => {
                        Iif (!this.active) {
                            return;
                        }
 
                        var label = _.escape(
                            i18n.getLabel(
                                groupType.labels,
                                UserContext.get('catalogLocale'),
                                groupType.code
                            )
                        );
 
                        PageTitle.set({'group type.label': _.escape(label) });
 
                        return FormBuilder.build('pim-group-type-edit-form')
                            .then((form) => {
                                this.on('pim:controller:can-leave', (event) => {
                                    form.trigger('pim_enrich:form:can-leave', event);
                                });
                                form.setData(groupType);
                                form.trigger('pim_enrich:form:entity:post_fetch', groupType);
                                form.setElement(this.$el).render();
 
                                return form;
                            });
                    });
            }
        });
    }
);