Important
You are browsing the documentation for version 3.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.
Component Shortcuts¶
Component Shortcuts provide ability to use simple widgets/modules without complicated data-page-component-* attributes. ComponentManager handle initialization of all registered shortcuts.
You can define component options in three different ways:
Empty Value¶
Example:
1 <div data-page-component-collapse>
2 Some content to collapse
3 </div>
1 // register shortcuts in ComponentShortcutsManager
2 var ComponentShortcutsManager = require('oroui/js/component-shortcuts-manager');
3
4 ComponentShortcutsManager.add('collapse', {
5 moduleName: 'oroui/js/app/components/jquery-widget-component',
6 options: {
7 widgetModule: 'oroui/js/widget/collapse-widget'
8 }
9 });
Object Value¶
Example:
1 <div data-page-component-collapse="{{ {storageKey: 'entityWorkflow' ~ entityId}|json_encode }}">
2 Some content to collapse
3 </div>
1 // register shortcuts in ComponentShortcutsManager
2 var ComponentShortcutsManager = require('oroui/js/component-shortcuts-manager');
3
4 ComponentShortcutsManager.add('collapse', {
5 moduleName: 'oroui/js/app/components/jquery-widget-component',
6 options: {
7 widgetModule: 'oroui/js/widget/collapse-widget'
8 }
9 });
Scalar Value¶
Remember to add scalarOption
to the shortcut.
Example:
1 <div data-page-component-jquery="oroui/js/widget/collapse-widget">
2 Some content to collapse
3 </div>
1 // register shortcuts in ComponentShortcutsManager
2 var ComponentShortcutsManager = require('oroui/js/component-shortcuts-manager');
3
4 ComponentShortcutsManager.add('jquery', {
5 moduleName: 'oroui/js/app/components/jquery-widget-component',
6 scalarOption: 'widgetModule'
7 });
ComponentShortcutsManager¶
ComponentShortcutsManager is used to register shortcuts. Also containing helper method getComponentData to generate data for component initialization by element attributes and shortcut config.
References: