Important
You are browsing documentation for version 5.0 of OroCommerce, OroCRM, and OroPlatform, maintained until August 2024 and supported until March 2026. See version 5.1 (the latest LTS version) of the Oro documentation for information on latest features.
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