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

93.33% Statements 14/15
50% Branches 1/2
100% Functions 6/6
93.33% Lines 14/15

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 57 58 59 60 61 62 63 64 65 66 67 68 69    8x                                                 8x   8x             8x   8x       8x               8x   8x   8x 1x   8x 8x 8x   8x              
'use strict';
 
define(
    [
        'underscore',
        'oro/translator',
        'pim/controller/front',
        'pim/form-builder',
        'pim/fetcher-registry',
        'pim/user-context',
        'pim/dialog',
        'pim/page-title',
        'pim/error',
        'pim/i18n'
    ],
    function (
        _,
        __,
        BaseController,
        FormBuilder,
        FetcherRegistry,
        UserContext,
        Dialog,
        PageTitle,
        Error,
        i18n
    ) {
        return BaseController.extend({
            initialize: function () {
                this.config = __moduleConfig;
            },
 
            /**
             * {@inheritdoc}
             */
            renderForm: function (route) {
                return FetcherRegistry.getFetcher(this.config.fetcher).fetch(route.params.code, {cached: false})
                    .then((group) => {
                        Iif (!this.active) {
                            return;
                        }
 
                        var label = _.escape(
                            i18n.getLabel(
                                group.labels,
                                UserContext.get('catalogLocale'),
                                group.code
                            )
                        );
 
                        PageTitle.set({'group.label': label });
 
                        return FormBuilder.build(group.meta.form)
                            .then((form) => {
                                this.on('pim:controller:can-leave', function (event) {
                                    form.trigger('pim_enrich:form:can-leave', event);
                                });
                                form.setData(group);
                                form.trigger('pim_enrich:form:entity:post_fetch', group);
                                form.setElement(this.$el).render();
 
                                return form;
                            });
                    });
            }
        });
    }
);