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

86.67% Statements 13/15
78.57% Branches 11/14
83.33% Functions 5/6
86.67% Lines 13/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    1132x 1132x             2693x   1x       1x   1x 1x     2693x                                     1570x       1570x 1569x 1535x       1570x        
'use strict';
 
define(['oro/translator', 'pim/controller/base', 'pim/error'], function (__, BaseController, Error) {
    return BaseController.extend({
        formPromise: null,
 
        /**
         * {@inheritdoc}
         */
        renderRoute: function (route, path) {
            this.formPromise = this.renderForm(route, path)
                .fail((response) => {
                    const message = response &&
                        response.responseJSON ?
                        response.responseJSON.message :
                        __('pim_enrich.entity.fallback.generic_error');
                    const status = response && response.status ? response.status : 500;
 
                    const errorView = new Error(message, status);
                    errorView.setElement(this.$el).render();
                });
 
            return this.formPromise;
        },
 
        /**
         * Render the from for given route
         *
         * @param {String} route
         * @param {String} path
         *
         * @return {Promise}
         */
        renderForm: function () {
            throw new Error('Method renderForm is abstract and must be implemented!');
        },
 
        /**
         * {@inheritdoc}
         */
        remove: function () {
            Iif (null === this.formPromise) {
                return;
            }
 
            this.formPromise.then((form) => {
                if (form && typeof form.shutdown === 'function') {
                    form.shutdown();
                }
            });
 
            BaseController.prototype.remove.apply(this, arguments);
        }
    });
});