[Core] Allow actions to have multiple categories

Allow actions to have multiple categories; this will allow
the properties action to be applicable as both a menu option
and a button in the view-control category, WTD-1062.
This commit is contained in:
Victor Woeltjen 2015-04-01 15:33:18 -07:00
parent 00551779fb
commit 087cea1445

View File

@ -84,11 +84,21 @@ define(
// Build up look-up tables // Build up look-up tables
actions.forEach(function (Action) { actions.forEach(function (Action) {
if (Action.category) { // Get an action's category or categories
actionsByCategory[Action.category] = var categories = Action.category || [];
actionsByCategory[Action.category] || [];
actionsByCategory[Action.category].push(Action); // Convert to an array if necessary
} categories = Array.isArray(categories) ?
categories : [categories];
// Store action under all relevant categories
categories.forEach(function (category) {
actionsByCategory[category] =
actionsByCategory[category] || [];
actionsByCategory[category].push(Action);
});
// Store action by ekey as well
if (Action.key) { if (Action.key) {
actionsByKey[Action.key] = actionsByKey[Action.key] =
actionsByKey[Action.key] || []; actionsByKey[Action.key] || [];