diff --git a/platform/commonUI/browse/src/creation/CreateMenuController.js b/platform/commonUI/browse/src/creation/CreateMenuController.js index 84f973d411..c65cdeb560 100644 --- a/platform/commonUI/browse/src/creation/CreateMenuController.js +++ b/platform/commonUI/browse/src/creation/CreateMenuController.js @@ -9,18 +9,26 @@ define( "use strict"; /** + * Controller for the Create menu; maintains an up-to-date + * set of Create actions based on the currently-selected + * domain object. * * @constructor */ function CreateMenuController($scope) { + // Update the set of Create actions function refreshActions() { - var actionCapability = $scope.action; - if (actionCapability) { - $scope.createActions = - actionCapability.getActions('create'); - } + $scope.createActions = $scope.action ? + $scope.action.getActions('create') : + []; } + // Listen for new instances of the represented object's + // "action" capability. This is provided by the mct-representation + // for the Create button. + // A watch is needed here (instead of invoking action.getActions + // directly) because different action instances may be returned + // with each call. $scope.$watch("action", refreshActions); }