mirror of
https://github.com/nasa/openmct.git
synced 2025-02-24 18:50:47 +00:00
[Common UI] Add JSDoc
Add JSDoc to classes from commonUI bundles. WTD-574.
This commit is contained in:
parent
49df6ee0ce
commit
078d63de36
@ -11,37 +11,63 @@ define(
|
|||||||
var ROOT_OBJECT = "ROOT";
|
var ROOT_OBJECT = "ROOT";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The BrowseController is used to populate the initial scope in Browse
|
||||||
|
* mode. It loads the root object from the objectService and makes it
|
||||||
|
* available in the scope for Angular template's; this is the point at
|
||||||
|
* which Angular templates first have access to the domain object
|
||||||
|
* hierarchy.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function BrowseController($scope, objectService, navigationService) {
|
function BrowseController($scope, objectService, navigationService) {
|
||||||
|
// Callback for updating the in-scope reference to the object
|
||||||
|
// that is currently navigated-to.
|
||||||
function setNavigation(domainObject) {
|
function setNavigation(domainObject) {
|
||||||
$scope.navigatedObject = domainObject;
|
$scope.navigatedObject = domainObject;
|
||||||
//$scope.$apply("navigatedObject");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load the root object, put it in the scope.
|
||||||
|
// Also, load its immediate children, and (possibly)
|
||||||
|
// navigate to one of them, so that navigation state has
|
||||||
|
// a useful initial value.
|
||||||
objectService.getObjects([ROOT_OBJECT]).then(function (objects) {
|
objectService.getObjects([ROOT_OBJECT]).then(function (objects) {
|
||||||
var composition = objects[ROOT_OBJECT].useCapability("composition");
|
var composition = objects[ROOT_OBJECT].useCapability("composition");
|
||||||
$scope.domainObject = objects[ROOT_OBJECT];
|
$scope.domainObject = objects[ROOT_OBJECT];
|
||||||
if (composition) {
|
if (composition) {
|
||||||
composition.then(function (c) {
|
composition.then(function (c) {
|
||||||
// Navigate to the last root level component (usually "mine")
|
// Check if an object has been navigated-to already...
|
||||||
if (!navigationService.getNavigation()) {
|
if (!navigationService.getNavigation()) {
|
||||||
|
// If not, pick a default as the last
|
||||||
|
// root-level component (usually "mine")
|
||||||
navigationService.setNavigation(c[c.length - 1]);
|
navigationService.setNavigation(c[c.length - 1]);
|
||||||
} else {
|
} else {
|
||||||
|
// Otherwise, just expose it in the scope
|
||||||
$scope.navigatedObject = navigationService.getNavigation();
|
$scope.navigatedObject = navigationService.getNavigation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Listen for changes in navigation state.
|
||||||
|
navigationService.addListener(setNavigation);
|
||||||
|
|
||||||
|
// Clean up when the scope is destroyed
|
||||||
$scope.$on("$destroy", function () {
|
$scope.$on("$destroy", function () {
|
||||||
navigationService.removeListener(setNavigation);
|
navigationService.removeListener(setNavigation);
|
||||||
});
|
});
|
||||||
|
|
||||||
navigationService.addListener(setNavigation);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
/**
|
||||||
|
* Navigate to a specific domain object.
|
||||||
|
*
|
||||||
|
* This is exposed so that the browse tree has a callback
|
||||||
|
* to invoke when the user clicks on a new object to navigate
|
||||||
|
* to it.
|
||||||
|
*
|
||||||
|
* @method
|
||||||
|
* @memberof BrowseController
|
||||||
|
* @param {DomainObject} domainObject the object to navigate to
|
||||||
|
*/
|
||||||
setNavigation: function (domainObject) {
|
setNavigation: function (domainObject) {
|
||||||
navigationService.setNavigation(domainObject);
|
navigationService.setNavigation(domainObject);
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,27 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The Create Action is performed to create new instances of
|
||||||
|
* domain objects of a specific type. This is the action that
|
||||||
|
* is performed when a user uses the Create menu.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @param {Type} type the type of domain object to create
|
||||||
|
* @param {DomainObject} parent the domain object that should
|
||||||
|
* act as a container for the newly-created object
|
||||||
|
* (note that the user will have an opportunity to
|
||||||
|
* override this)
|
||||||
|
* @param {ActionContext} context the context in which the
|
||||||
|
* action is being performed
|
||||||
|
* @param {DialogService} dialogService the dialog service
|
||||||
|
* to use when requesting user input
|
||||||
|
* @param {CreationService} creationService the creation service,
|
||||||
|
* which handles the actual instantiation and persistence
|
||||||
|
* of the newly-created domain object
|
||||||
*/
|
*/
|
||||||
function CreateAction(type, parent, context, dialogService, creationService) {
|
function CreateAction(type, parent, context, dialogService, creationService) {
|
||||||
/*
|
/*
|
||||||
|
Overview of steps in object creation:
|
||||||
|
|
||||||
1. Show dialog
|
1. Show dialog
|
||||||
a. Prepare dialog contents
|
a. Prepare dialog contents
|
||||||
@ -26,12 +42,15 @@ define(
|
|||||||
b. Add new id to composition
|
b. Add new id to composition
|
||||||
4. Persist destination container
|
4. Persist destination container
|
||||||
a. ...use persistence capability.
|
a. ...use persistence capability.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function perform() {
|
function perform() {
|
||||||
|
// The wizard will handle creating the form model based
|
||||||
|
// on the type...
|
||||||
var wizard = new CreateWizard(type, parent);
|
var wizard = new CreateWizard(type, parent);
|
||||||
|
|
||||||
|
// Create and persist the new object, based on user
|
||||||
|
// input.
|
||||||
function persistResult(formValue) {
|
function persistResult(formValue) {
|
||||||
var parent = wizard.getLocation(formValue),
|
var parent = wizard.getLocation(formValue),
|
||||||
newModel = wizard.createModel(formValue);
|
newModel = wizard.createModel(formValue);
|
||||||
@ -49,7 +68,24 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
/**
|
||||||
|
* Create a new object of the given type.
|
||||||
|
* This will prompt for user input first.
|
||||||
|
* @method
|
||||||
|
* @memberof CreateAction
|
||||||
|
*/
|
||||||
perform: perform,
|
perform: perform,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get metadata about this action. This includes fields:
|
||||||
|
* * `name`: Human-readable name
|
||||||
|
* * `key`: Machine-readable identifier ("create")
|
||||||
|
* * `glyph`: Glyph to use as an icon for this action
|
||||||
|
* * `description`: Human-readable description
|
||||||
|
* * `context`: The context in which this action will be performed.
|
||||||
|
*
|
||||||
|
* @return {object} metadata about the create action
|
||||||
|
*/
|
||||||
getMetadata: function () {
|
getMetadata: function () {
|
||||||
return {
|
return {
|
||||||
key: 'create',
|
key: 'create',
|
||||||
|
@ -9,20 +9,42 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The CreateActionProvider is an ActionProvider which introduces
|
||||||
|
* a Create action for each creatable domain object type.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @param {TypeService} typeService the type service, used to discover
|
||||||
|
* available types
|
||||||
|
* @param {DialogService} dialogService the dialog service, used by
|
||||||
|
* specific Create actions to get user input to populate the
|
||||||
|
* model of the newly-created domain object.
|
||||||
|
* @param {CreationService} creationService the creation service (also
|
||||||
|
* introduced in this bundle), responsible for handling actual
|
||||||
|
* object creation.
|
||||||
*/
|
*/
|
||||||
function CreateActionProvider(typeService, dialogService, creationService) {
|
function CreateActionProvider(typeService, dialogService, creationService) {
|
||||||
return {
|
return {
|
||||||
|
/**
|
||||||
|
* Get all Create actions which are applicable in the provided
|
||||||
|
* context.
|
||||||
|
* @memberof CreateActionProvider
|
||||||
|
* @method
|
||||||
|
* @returns {CreateAction[]}
|
||||||
|
*/
|
||||||
getActions: function (actionContext) {
|
getActions: function (actionContext) {
|
||||||
var context = actionContext || {},
|
var context = actionContext || {},
|
||||||
key = context.key,
|
key = context.key,
|
||||||
destination = context.domainObject;
|
destination = context.domainObject;
|
||||||
|
|
||||||
|
// We only provide Create actions, and we need a
|
||||||
|
// domain object to serve as the container for the
|
||||||
|
// newly-created object (although the user may later
|
||||||
|
// make a different selection)
|
||||||
if (key !== 'create' || !destination) {
|
if (key !== 'create' || !destination) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Introduce one create action per type
|
||||||
return typeService.listTypes().map(function (type) {
|
return typeService.listTypes().map(function (type) {
|
||||||
return new CreateAction(
|
return new CreateAction(
|
||||||
type,
|
type,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user