All files / web/bundles/pimdatagrid/js/datagrid/action navigate-action.js

90% Statements 9/10
75% Branches 3/4
100% Functions 4/4
90% Lines 9/10

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 57 58 59 60 61 62 63  765x                     765x                                 26357x   26357x       26357x   26357x 3307x                     22x                 22x        
/* global define */
define(['underscore', 'oro/mediator', 'oro/datagrid/model-action', 'pim/router'],
function(_, mediator, ModelAction, router) {
    'use strict';
 
    /**
     * Navigate action. Changes window location to url, from getLink method
     *
     * @export  oro/datagrid/navigate-action
     * @class   oro.datagrid.NavigateAction
     * @extends oro.datagrid.ModelAction
     */
    return ModelAction.extend({
 
        /**
         * If `true` then created launcher will be complete clickable link,
         * If `false` redirection will be delegated to execute method.
         *
         * @property {Boolean}
         */
        useDirectLauncherLink: true,
 
        /**
         * Initialize launcher options with url
         *
         * @param {Object} options
         * @param {Boolean} options.useDirectLauncherLink
         */
        initialize: function(options) {
            ModelAction.prototype.initialize.apply(this, arguments);
 
            Iif (options.useDirectLauncherLink) {
                this.useDirectLauncherLink = options.useDirectLauncherLink;
            }
 
            this.on('preExecute', _.bind(this._preExecuteSubscriber, this));
 
            if (this.useDirectLauncherLink) {
                this.launcherOptions = _.extend({
                    link: this.getLink(),
                    runAction: false
                }, this.launcherOptions);
            }
        },
 
        /**
         * Execute redirect
         */
        execute: function() {
            router.redirect(this.getLink());
        },
 
        /**
         * Trigger global event
         *
         * @private
         */
        _preExecuteSubscriber: function(action, options) {
            mediator.trigger('grid_action:navigateAction:preExecute', action, options);
        }
    });
});