3. contextMenuItems
Context menu items can have a lot of options and functionality. Therefore there is a lot to configure. For each item add a contentNode with the following nodeDatas: - type: Optional context menu item type, either menuItem or separator. Separators don't need any other settings than this one.
- name: The name of the menu item, e.g. "copy"
- label: The label or message key for the menu item, e.g. tree.config.menu.copy
- icon: An optional path to an icon to be displayed to the left of the menu item, e.g. "/.resources/icons/16/folder_cubes.gif"
- onClick: JavaScript method which should executed when the menu item is clicked, e.g. "createNode('mgnl:content')"
- requiresActiveSubscriber: Boolean to mark if there must be an active subscriber in order for this menu item to be active
- [TODO: implement and describe more options here.]
In addition to these nodeDatas you can also add JavaScript conditions which will deactivate the menu item when they return false. You can add multiple conditions which all have to result in true in order for the menu item to be active. Place the conditions in a contentNode named "javascriptConditions". Add a nodeData for each condition inside this "javascriptConditions" contentNode. You can name them whatever you like (e.g. "0", "1", "2"). A sample condition could look like this: nodeData 0: new mgnlTreeMenuItemConditionSelectedNotItemType(${tree}, 'ffProject') If you would like to know what conditions are already available, have a look at /magnolia-module-admininterface/src/main/resources/mgnl-resources/admin-js/contextmenu.js. Maybe there are additional conditions in other JavaScript files in other modules too… NOTE 1: You might have noticed the "${tree}" placeholder in the JavaScript condition call above. The JavaScript methods you call often need a reference to the JavaScript tree object. Since we don't know this variable name at compile time, we need to provide a placeholder: ${tree}. At runtime, the conditions are parsed and this placeholder will be replaced by the name of the actual JavaScript tree variable. This can also be the case for "onClick" actions, e.g. mgnl.data.DataTree.create(${tree}.selectedNode.id, 'myNodeType') NOTE 2: If you add conditions you need to make sure that the icon for the menu item also exists in a "inactive" version. It should be called the same with "_inactive" added to the file name and MUST be a GIF. So an icon "project.png" should have a "project_inactive.gif" version. A menu configuration could look like this: 
|