Important

You are browsing the documentation for version 4.2 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Action Manager

Action Manager enables you to add actions globally for all jsTree in the application, in one place

ActionManager.addAction(name, action) method takes two arguments {name, action}

  • ‘name’ - a unique action identifier

  • ‘action’ - an object with a view instance and a hook property, when this property contain true, action is appended to the tree view

{
    view: 'path/to/some-action-view',
    hook: 'someProperty'
}

or hook parameter can get multiple properties

{
    view: 'path/to/some-action-view',
    hook: {
        someProperty: true,
        someProperty2: 'string' or 'number'
    }
}

Example of Usage

// Create action

    var AbstractActionView = require('oroui/js/app/views/jstree/abstract-action-view');

    SomeActionView = AbstractActionView.extend({
        options: _.extend({}, AbstractActionView.prototype.options, {
            icon: 'custom-icon',
            label: 'Custom Label'
        }),


        onClick: function() {

            // Get jstree instance

            var $tree = this.options.$tree;

            // Get jstree settings

            var settings = $tree.jstree().settings;

            // Add here action functionality
        }
    });

    return SomeActionView;

// Register new action


    var ActionManager = require('oroui/js/jstree-action-manager');
    var SomeActionView_1 = require('oroui/js/app/views/jstree/some-action-view-1');
    var SomeActionView_2 = require('oroui/js/app/views/jstree/some-action-view-2');

    ActionManager.addAction('subtree', {
        view: SomeActionView_1,
        hook: 'someProperty'
    });

    ActionManager.addAction('subtree', {
        view: SomeActionView_2,
        hook: {
            someProperty: true,
            someProperty2: 'some string'
        }
    });

Hint

See more examples in ActionManager.addAction oroui/js/app/modules/jstree-actions-module.js