[Common UI] Add JSDoc for CreateMenuController

Add JSDoc and clarifying comments to the CreateMenuController,
which is responsible for maintaining an up-to-date set of
Create actions for a given domain object. WTD-574.
This commit is contained in:
Victor Woeltjen 2014-11-24 07:20:49 -08:00
parent 6e9d6e2199
commit 845c1ad7d7

View File

@ -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);
}