This is an extension of the standard menu item where the menu item has on and off toggle state represented by a check mark. The menu items can be placed in a group so that only one item within the group can be checked at a time or can be used as individual items for toggling things on or off. Each time the a menu item is actioned it will publish on the configured topic and the payload will include a "selected" attribute indicating whether or not the item has been toggled to the on or off state. Items can be grouped by simply assigning multiple items with the same group value. The other items in the group will automatically be toggled to the off state when another item is toggled to the on state.
- Copyright:
- Copyright (C) 2005-2020 Alfresco Software Limited
- License:
- GNU Lesser General Public License, see: Open Source Licensing
- Source:
Examples
{
name: "alfresco/menus/AlfCheckableMenuItem",
config: {
label: "Checkable",
value: "SOME_VALUE",
checked: true,
publishTopic: "CUSTOM_TOPIC",
publishPayload: {
additional: "bonus data"
}
}
}
{
name: "alfresco/menus/AlfCheckableMenuItem",
config: {
label: "Grouped Checkable",
value: "SOME_VALUE",
group: "GROUP1",
publishTopic: "CUSTOM_TOPIC"
}
}
Members
-
checkCell :object
-
A reference to the cell that will be created by postCreate to handle toggling selection
Type:
- object
- Default Value:
- null
- Source:
-
checked :boolean
-
Indicates whether or not the menu item is selected or not
Type:
- boolean
- Default Value:
- false
- Source:
-
checkedIconClass :string
-
The class to apply to render some checked indicator
Type:
- string
- Default Value:
- "alfresco-menus-AlfCheckableMenuItem--checked"
- Source:
-
closeOnClick :boolean
-
Overrides the default value provided by the _AlfMenuItemMixin
Type:
- boolean
- Default Value:
- true
- Source:
-
cssRequirements :object[]
-
An array of the CSS files to use with this widget.
Type:
- object[]
- Default Value:
- [{cssFile:"./css/AlfCheckableMenuItem.css"}]
- Source:
-
group :string
-
If this is set then it indicates that this item is a member of a group. When in a group this cannot be unselected. Unselection will only occur when another item in the group is selected. Setting this attribute to anything other than null makes this item behave as though it were a member of a radio button group.
Type:
- string
- Default Value:
- null
- Source:
-
hashName :string
-
If this instance should be set according to a hash fragment value then this attribute should be set to the name of the fragment parameter to use. If the hash fragment parameter exists and its value matches the current value then this will automatically be checked.
Type:
- string
- Default Value:
- null
- Source:
-
publishPayload :object
-
The payload that will be published when the item is selected
Type:
- object
- Default Value:
- null
- Source:
-
subscriptionHandle :object
-
A handle to the publication topic. This is set initially in post create and then removed just before publishing to prevent a widget handling its own generated event
Type:
- object
- Default Value:
- null
- Source:
Methods
-
onClick(evt)
-
Parameters:
Name Type Description evt
object The click event - Source:
-
onGroupSelection(payload)
-
This function is called when a topic is published indicating that another member of the group has been selected. The payload is irrelevant, the menu item should be marked as deslected.
Parameters:
Name Type Description payload
object - Source:
-
onPublishTopicEvent(payload)
-
Handles the events published on the publish topic. This allows the widget to update itself based on events generated by other widgets.
Parameters:
Name Type Description payload
object The payload published on the subscribed topic - Source:
-
postCreate()
-
- Source:
-
publishSelection()
-
Handles publishing the selection event.
- Source:
-
render()
-
Renders the menu item appropriately according to the current checked value. By default this simply adds or removes the 'checkedIconClass' from the checkCell appropriately
- Source:
-
toggleSelection(evt)
-
Parameters:
Name Type Description evt
object The click event that resulted in the toggle - Source: