[Common UI] Add JSDoc

Add JSDoc to remaining scripts in bundle
platform/commonUI/general. WTD-574.
This commit is contained in:
Victor Woeltjen
2014-11-24 16:39:52 -08:00
parent 2f43e8cd7f
commit 80430234d6
3 changed files with 51 additions and 1 deletions

View File

@@ -9,10 +9,24 @@ define(
"use strict";
/**
* Controller which keeps an up-to-date list of actions of
* a certain category, and additionally bins them into
* groups as described by their metadata. Used specifically
* to support button groups.
*
* This will maintain two fields in the scope:
* * `groups`: An array of arrays. Each element in the outer
* array corresponds to a group; the inner array contains
* the actions which are in that group.
* * `ungrouped`: All actions which did not have a defined
* group.
*
* @constructor
*/
function ActionGroupController($scope) {
// Separate out the actions that have been retrieved
// into groups, and populate scope with this.
function groupActions(actions) {
var groups = {},
ungrouped = [];
@@ -36,20 +50,31 @@ define(
});
}
// Callback for when state which might influence action groupings
// changes.
function updateGroups() {
var actionCapability = $scope.action,
params = $scope.parameters || {},
category = params.category;
if (actionCapability && category) {
groupActions(actionCapability.getActions({ category: category }));
// Get actions by capability, and group them
groupActions(actionCapability.getActions({
category: category
}));
} else {
// We don't have enough information to get any actions.
groupActions([]);
}
}
// Changes to the represented object, to its action capability, or
// to the chosen action category may all require an update.
$scope.$watch("domainObject", updateGroups);
$scope.$watch("action", updateGroups);
$scope.$watch("parameters.category", updateGroups);
// Start with empty arrays.
$scope.ungrouped = [];
$scope.groups = [];
}