All files / web/bundles/pimui/js/controller entity-with-family-variant.js

100% Statements 12/12
100% Branches 2/2
100% Functions 5/5
100% Lines 12/12

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    305x                       305x         388x   388x 3x     385x       385x   383x 32x   383x   383x   383x              
'use strict';
 
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(this.options.config.entity).fetch(route.params.id, {cached: false})
                    .then((product) => {
                        if (!this.active) {
                            return;
                        }
 
                        PageTitle.set(
                            { 'product.label': product.meta.label[UserContext.get('catalogLocale')] }
                        );
 
                        return FormBuilder.build(product.meta.form)
                            .then((form) => {
                                this.on('pim:controller:can-leave', function (event) {
                                    form.trigger('pim_enrich:form:can-leave', event);
                                });
                                form.setData(product);
 
                                form.setElement(this.$el).render();
 
                                return form;
                            });
                    });
            }
        });
    }
);