mirror of
https://github.com/nasa/openmct.git
synced 2025-04-20 00:51:09 +00:00
[Tree] Begin adding controller for refactored tree
This commit is contained in:
parent
baab0be5af
commit
3b0a3733b4
@ -23,15 +23,51 @@
|
||||
|
||||
define([
|
||||
'text!../../res/templates/subtree.html'
|
||||
], function () {
|
||||
function MCTTree() {
|
||||
function link(scope, elem) {
|
||||
], function (subtreeTemplate) {
|
||||
function MCTTreeController($scope, $element) {
|
||||
var ul = elem.filter('ul'),
|
||||
activeObject,
|
||||
unlisten;
|
||||
|
||||
function addNodes(domainObjects) {
|
||||
domainObjects.forEach(function (addNode));
|
||||
}
|
||||
|
||||
function loadComposition(domainObject) {
|
||||
activeObject = domainObject;
|
||||
ul.empty();
|
||||
if (domainObject.hasCapability('composition')) {
|
||||
// TODO: Add pending indicator
|
||||
domainObject.useCapability('composition')
|
||||
.then(addNodes);
|
||||
}
|
||||
}
|
||||
|
||||
function changeObject(domainObject) {
|
||||
if (unlisten) {
|
||||
unlisten();
|
||||
}
|
||||
|
||||
unlisten = domainObject.getCapability('mutation')
|
||||
.listen(loadComposition);
|
||||
|
||||
loadComposition(domainObject);
|
||||
}
|
||||
|
||||
scope.$watch('mctObject', changeObject);
|
||||
}
|
||||
|
||||
function MCTTree() {
|
||||
return {
|
||||
link: link,
|
||||
scope: { mctModel: "=" }
|
||||
restrict: "E",
|
||||
controller: [
|
||||
'$scope',
|
||||
'$element',
|
||||
MCTTreeController
|
||||
],
|
||||
require: [ "mctTree" ],
|
||||
scope: { mctObject: "=" },
|
||||
template: subtreeTemplate
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user