mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 13:18:15 +00:00
[Entanglement] Add entanglement bundle
The entanglement bundle defines move, copy, and link actions, and exposes them as context menu actions. * The Move action moves an object from it's current parent to a new parent object. * The Copy action deep-copies an object to a new parent object. * The Link action links an object to a new parent object. These actions are implemented by three new services: moveService, copyService, and linkService. Mocks are provided for each service for easy testing of components that depend on them. Additionally, this bundle provides a DomainObjectFactory that simplifies the construction of mockDomainObjects for tests. These actions are exposed to the user as context menu options.
This commit is contained in:
61
platform/entanglement/src/services/LocationService.js
Normal file
61
platform/entanglement/src/services/LocationService.js
Normal file
@ -0,0 +1,61 @@
|
||||
/*global define */
|
||||
|
||||
define(
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* The LocationService allows for easily prompting the user for a
|
||||
* location in the root tree.
|
||||
*/
|
||||
function LocationService(dialogService) {
|
||||
return {
|
||||
/** Prompt the user to select a location. Returns a promise
|
||||
* that is resolved with a domainObject representing the
|
||||
* location selected by the user.
|
||||
*
|
||||
* @param {string} title - title of location dialog
|
||||
* @param {string} label - label for location input field
|
||||
* @param {function} validate - function that validates
|
||||
* selections.
|
||||
* @param {domainObject} initialLocation - tree location to
|
||||
* display at start
|
||||
* @returns {Promise} promise for a domain object.
|
||||
*/
|
||||
getLocationFromUser: function (title, label, validate, initialLocation) {
|
||||
var formStructure,
|
||||
formState;
|
||||
|
||||
formStructure = {
|
||||
sections: [
|
||||
{
|
||||
name: 'Location',
|
||||
rows: [
|
||||
{
|
||||
name: label,
|
||||
control: "locator",
|
||||
validate: validate,
|
||||
key: 'location'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
name: title
|
||||
};
|
||||
|
||||
formState = {
|
||||
location: initialLocation
|
||||
};
|
||||
|
||||
return dialogService
|
||||
.getUserInput(formStructure, formState)
|
||||
.then(function (formState) {
|
||||
return formState.location;
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return LocationService;
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user