From 087cea1445a87149379476a74c038c17ca233944 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 1 Apr 2015 15:33:18 -0700 Subject: [PATCH] [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. --- platform/core/src/actions/ActionProvider.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/platform/core/src/actions/ActionProvider.js b/platform/core/src/actions/ActionProvider.js index 995dd68bc3..19b5504ad1 100644 --- a/platform/core/src/actions/ActionProvider.js +++ b/platform/core/src/actions/ActionProvider.js @@ -84,11 +84,21 @@ define( // Build up look-up tables actions.forEach(function (Action) { - if (Action.category) { - actionsByCategory[Action.category] = - actionsByCategory[Action.category] || []; - actionsByCategory[Action.category].push(Action); - } + // Get an action's category or categories + var categories = Action.category || []; + + // 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) { actionsByKey[Action.key] = actionsByKey[Action.key] || [];