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 the updated 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
3
4
 {
     view: 'path/to/some-action-view',
     hook: 'someProperty'
 }

or hook parameter can get multiple properties

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

Example of Usage

 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
 // 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