mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 06:03:08 +00:00
[Forms] Add Locator control
Add Locator form control, to allow selection of a destination for newly-created domain objects in a tree. WTD-593.
This commit is contained in:
parent
9dd0a54568
commit
2476941eb2
@ -30,6 +30,17 @@
|
||||
"key": "CreateMenuController",
|
||||
"implementation": "creation/CreateMenuController",
|
||||
"depends": [ "$scope" ]
|
||||
},
|
||||
{
|
||||
"key": "LocatorController",
|
||||
"implementation": "creation/LocatorController",
|
||||
"depends": [ "$scope" ]
|
||||
}
|
||||
],
|
||||
"controls": [
|
||||
{
|
||||
"key": "locator",
|
||||
"templateUrl": "templates/create/locator.html"
|
||||
}
|
||||
],
|
||||
"templates": [
|
||||
|
@ -0,0 +1,8 @@
|
||||
<div ng-controller="LocatorController" class="selector-list">
|
||||
<div>
|
||||
<mct-representation key="'tree'"
|
||||
mct-object="rootObject"
|
||||
ng-model="treeModel">
|
||||
</mct-representation>
|
||||
</div>
|
||||
</div>
|
39
platform/commonUI/browse/src/creation/LocatorController.js
Normal file
39
platform/commonUI/browse/src/creation/LocatorController.js
Normal file
@ -0,0 +1,39 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Controller for the "locator" control, which provides the
|
||||
* user with the ability to select a domain object as the
|
||||
* destination for a newly-created object in the Create menu.
|
||||
* @constructor
|
||||
*/
|
||||
function LocatorController($scope) {
|
||||
// Populate values needed by the locator control. These are:
|
||||
// * rootObject: The top-level object, since we want to show
|
||||
// the full tree
|
||||
// * treeModel: The model for the embedded tree representation,
|
||||
// used for bi-directional object selection.
|
||||
function setLocatingObject(domainObject) {
|
||||
var context = domainObject &&
|
||||
domainObject.getCapability("context");
|
||||
|
||||
$scope.rootObject = context && context.getRoot();
|
||||
$scope.treeModel.selectedObject = domainObject;
|
||||
$scope.ngModel[$scope.field] = domainObject;
|
||||
}
|
||||
|
||||
// Initial state for the tree's model
|
||||
$scope.treeModel =
|
||||
{ selectedObject: $scope.ngModel[$scope.field] };
|
||||
|
||||
// Watch for changes from the tree
|
||||
$scope.$watch("treeModel.selectedObject", setLocatingObject);
|
||||
}
|
||||
|
||||
return LocatorController;
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue
Block a user