Sha256: 98b35c3da4bd42680fbf42a73f567d0435508901d344daa225913d2e58c8f5d7

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

/**
 * @namespace WORKAREA.impersonationNotification
 */
WORKAREA.registerModule('impersonationNotification', (function () {
    'use strict';

    var pathExcluded = function () {
            var paths = WORKAREA.config.impersonationNotification.excludedPaths;

            return _.reduce(paths, function (result, path) {
                return _.includes(window.location.pathname, path);
            }, false);
        },

        confirm = function ($form) {
            var confirmed = window.confirm(
                I18n.t('workarea.admin.actions.impersonation_confirmation', {
                    name: $form.data('impersonationNotification')
                })
            );

            if (confirmed) { return; }

            $form.trigger('submit');
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.impersonationNotification
         */
        init = _.once(function ($scope) {
            var $form = $('[data-impersonation-notification]', $scope);

            if (_.isEmpty($form)) { return; }
            if (pathExcluded()) { return; }

            confirm($form);
        });

    return {
        init: init
    };
}()));

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-admin-3.5.0.beta.1 app/assets/javascripts/workarea/admin/modules/impersonation_notification.js