All files / web/bundles/pimui/js/controller job-instance.js

93.33% Statements 14/15
83.33% Branches 5/6
100% Functions 5/5
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    359x                       359x         433x 433x   433x   432x       432x   432x   424x 377x   424x 424x 424x   424x              
'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) {
                var type = route.name.indexOf('pim_importexport_import') === -1 ? 'export' : 'import';
                var mode = route.name.indexOf('_profile_show') === -1 ? 'edit' : 'show';
 
                return FetcherRegistry.getFetcher('job-instance-' + type).fetch(route.params.code, {cached: false})
                    .then((jobInstance) => {
                        Iif (!this.active) {
                            return;
                        }
 
                        PageTitle.set({'job.label': _.escape(jobInstance.label) });
 
                        return FormBuilder.build(jobInstance.meta.form + '-' + mode)
                            .then((form) => {
                                this.on('pim:controller:can-leave', (event) => {
                                    form.trigger('pim_enrich:form:can-leave', event);
                                });
                                form.setData(jobInstance);
                                form.trigger('pim_enrich:form:entity:post_fetch', jobInstance);
                                form.setElement(this.$el).render();
 
                                return form;
                            });
                    });
            }
        });
    }
);