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

100% Statements 16/16
100% Branches 2/2
100% Functions 7/7
100% Lines 16/16

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    411x               411x         774x     766x 30x     736x   604x 6x   604x 604x   604x 358x   604x   604x           440x   440x          
'use strict';
 
define(
    [
        'underscore',
        'pim/controller/front',
        'pim/form-builder',
        'pim/fetcher-registry'
    ],
    function (_, BaseController, FormBuilder, FetcherRegistry) {
        return BaseController.extend({
            /**
             * {@inheritdoc}
             */
            renderForm: function (route) {
                return FetcherRegistry.getFetcher('job-execution').fetch(
                        route.params.id, {id: route.params.id, cached: false}
                    ).then((jobExecution) => {
                        if (!this.active) {
                            return;
                        }
 
                        return FormBuilder.build('pim-job-execution-form')
                            .then((form) => {
                                this.on('pim:controller:can-leave', function (event) {
                                    form.trigger('pim_enrich:form:can-leave', event);
                                });
                                form.setData(jobExecution);
                                form.getRoot().trigger('pim-job-execution-form:start-auto-update', jobExecution);
 
                                this.on('pim-controller:job-execution:remove', () => {
                                    form.getRoot().trigger('pim-job-execution-form:stop-auto-update');
                                });
                                form.setElement(this.$el).render();
 
                                return form;
                            });
                    });
            },
 
            remove: function () {
                this.trigger('pim-controller:job-execution:remove');
 
                BaseController.prototype.remove.apply(this, arguments);
            }
        });
    }
);