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

83.33% Statements 10/12
75% Branches 3/4
100% Functions 4/4
83.33% Lines 10/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 47 48 49 50    8x                         8x         8x 8x           8x                   3x 3x   3x   3x 1x            
'use strict';
 
define([
        'jquery',
        'pim/controller/form',
        'pim/security-context',
        'pim/form-config-provider',
        'pim/router'
    ], function (
        $,
        FormController,
        securityContext,
        configProvider,
        router
    ) {
        return FormController.extend({
            /**
             * {@inheritdoc}
             */
            renderRoute: function (route, path) {
                return securityContext.initialize().then(() => {
                    Iif (!securityContext.isGranted('pim_user_role_edit')) {
                        router.redirectToRoute('pim_dashboard_index');
 
                        return;
                    }
 
                    return $.get(path)
                        .then(this.renderTemplate.bind(this))
                        .promise();
                })
            },
 
            /**
             * {@inheritdoc}
             */
            afterSubmit: function () {
                securityContext.initialize();
                configProvider.clear();
 
                FormController.prototype.afterSubmit.apply(this, arguments);
 
                if (!this.$('#entity-updated span').is(':visible')) {
                    location.reload();
                }
            }
        });
    }
);