mirror of
https://github.com/nasa/openmct.git
synced 2025-01-27 06:39:21 +00:00
[Common UI] Add JSDoc
Add JSDoc to remaining scripts in bundle platform/commonUI/general. WTD-574.
This commit is contained in:
parent
2f43e8cd7f
commit
80430234d6
@ -9,10 +9,24 @@ define(
|
|||||||
"use strict";
|
"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
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function ActionGroupController($scope) {
|
function ActionGroupController($scope) {
|
||||||
|
|
||||||
|
// Separate out the actions that have been retrieved
|
||||||
|
// into groups, and populate scope with this.
|
||||||
function groupActions(actions) {
|
function groupActions(actions) {
|
||||||
var groups = {},
|
var groups = {},
|
||||||
ungrouped = [];
|
ungrouped = [];
|
||||||
@ -36,20 +50,31 @@ define(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Callback for when state which might influence action groupings
|
||||||
|
// changes.
|
||||||
function updateGroups() {
|
function updateGroups() {
|
||||||
var actionCapability = $scope.action,
|
var actionCapability = $scope.action,
|
||||||
params = $scope.parameters || {},
|
params = $scope.parameters || {},
|
||||||
category = params.category;
|
category = params.category;
|
||||||
|
|
||||||
if (actionCapability && 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("domainObject", updateGroups);
|
||||||
$scope.$watch("action", updateGroups);
|
$scope.$watch("action", updateGroups);
|
||||||
$scope.$watch("parameters.category", updateGroups);
|
$scope.$watch("parameters.category", updateGroups);
|
||||||
|
|
||||||
|
// Start with empty arrays.
|
||||||
$scope.ungrouped = [];
|
$scope.ungrouped = [];
|
||||||
$scope.groups = [];
|
$scope.groups = [];
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,20 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Controller for the context menu. Maintains an up-to-date
|
||||||
|
* list of applicable actions (those from category "contextual")
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function ContextMenuController($scope) {
|
function ContextMenuController($scope) {
|
||||||
|
// Refresh variable "menuActions" in the scope
|
||||||
function updateActions() {
|
function updateActions() {
|
||||||
$scope.menuActions = $scope.action ?
|
$scope.menuActions = $scope.action ?
|
||||||
$scope.action.getActions({ category: 'contextual' }) :
|
$scope.action.getActions({ category: 'contextual' }) :
|
||||||
[];
|
[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update using the action capability
|
||||||
$scope.$watch("action", updateActions);
|
$scope.$watch("action", updateActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,14 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The mct-container is similar to the mct-include directive
|
||||||
|
* insofar as it allows templates to be referenced by
|
||||||
|
* symbolic keys instead of by URL. Unlike mct-include, it
|
||||||
|
* supports transclusion.
|
||||||
|
*
|
||||||
|
* Unlike mct-include, mct-container accepts a key as a
|
||||||
|
* plain string attribute, instead of as an Angular
|
||||||
|
* expression.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
@ -27,9 +35,18 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
// Allow only at the element level
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
|
|
||||||
|
// Support transclusion
|
||||||
transclude: true,
|
transclude: true,
|
||||||
|
|
||||||
|
// Create a new (non-isolate) scope
|
||||||
scope: true,
|
scope: true,
|
||||||
|
|
||||||
|
// Populate initial scope based on attributes requested
|
||||||
|
// by the container definition
|
||||||
link: function (scope, element, attrs) {
|
link: function (scope, element, attrs) {
|
||||||
var key = attrs.key,
|
var key = attrs.key,
|
||||||
container = containerMap[key],
|
container = containerMap[key],
|
||||||
@ -45,10 +62,14 @@ define(
|
|||||||
|
|
||||||
scope[alias] = copiedAttributes;
|
scope[alias] = copiedAttributes;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Get the template URL for this container, based
|
||||||
|
// on its attributes.
|
||||||
templateUrl: function (element, attrs) {
|
templateUrl: function (element, attrs) {
|
||||||
var key = attrs.key;
|
var key = attrs.key;
|
||||||
return containerMap[key].templateUrl;
|
return containerMap[key].templateUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user