mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 15:18:12 +00:00
[Tree] Begin adding controller for refactored tree
This commit is contained in:
@ -23,15 +23,51 @@
|
|||||||
|
|
||||||
define([
|
define([
|
||||||
'text!../../res/templates/subtree.html'
|
'text!../../res/templates/subtree.html'
|
||||||
], function () {
|
], function (subtreeTemplate) {
|
||||||
function MCTTree() {
|
function MCTTreeController($scope, $element) {
|
||||||
function link(scope, elem) {
|
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 {
|
return {
|
||||||
link: link,
|
restrict: "E",
|
||||||
scope: { mctModel: "=" }
|
controller: [
|
||||||
|
'$scope',
|
||||||
|
'$element',
|
||||||
|
MCTTreeController
|
||||||
|
],
|
||||||
|
require: [ "mctTree" ],
|
||||||
|
scope: { mctObject: "=" },
|
||||||
|
template: subtreeTemplate
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user