Important

You are browsing the documentation for version 4.1 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

1 {
2     view: 'path/to/some-action-view',
3     hook: 'someProperty'
4 }

or hook parameter can get multiple properties

1 {
2     view: 'path/to/some-action-view',
3     hook: {
4         someProperty: true,
5         someProperty2: 'string' or 'number'
6     }
7 }

Example of Usage

 1 // Create action
 2
 3     var AbstractActionView = require('oroui/js/app/views/jstree/abstract-action-view');
 4
 5     SomeActionView = AbstractActionView.extend({
 6         options: _.extend({}, AbstractActionView.prototype.options, {
 7             icon: 'custom-icon',
 8             label: 'Custom Label'
 9         }),
10
11
12         onClick: function() {
13
14             // Get jstree instance
15
16             var $tree = this.options.$tree;
17
18             // Get jstree settings
19
20             var settings = $tree.jstree().settings;
21
22             // Add here action functionality
23         }
24     });
25
26     return SomeActionView;
27
28 // Register new action
29
30
31     var ActionManager = require('oroui/js/jstree-action-manager');
32     var SomeActionView_1 = require('oroui/js/app/views/jstree/some-action-view-1');
33     var SomeActionView_2 = require('oroui/js/app/views/jstree/some-action-view-2');
34
35     ActionManager.addAction('subtree', {
36         view: SomeActionView_1,
37         hook: 'someProperty'
38     });
39
40     ActionManager.addAction('subtree', {
41         view: SomeActionView_2,
42         hook: {
43             someProperty: true,
44             someProperty2: 'some string'
45         }
46     });

Hint

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