mirror of
https://github.com/nasa/openmct.git
synced 2025-04-22 18:11:23 +00:00
[Tree] Begin wiring in selection
This commit is contained in:
parent
03ab3bddc4
commit
82b6166408
platform/commonUI/general
@ -19,6 +19,6 @@
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<mct-tree mct-object="domainObject">
|
||||
<mct-tree mct-object="domainObject" mct-model="ngModel.selectedObject">
|
||||
</mct-tree>
|
||||
|
||||
|
@ -25,13 +25,17 @@ define([
|
||||
'angular',
|
||||
'../ui/TreeView'
|
||||
], function (angular, TreeView) {
|
||||
function MCTTree() {
|
||||
function link(scope, element) {
|
||||
var treeView = new TreeView();
|
||||
function MCTTree($parse) {
|
||||
function link(scope, element, attrs) {
|
||||
var treeView = new TreeView(),
|
||||
expr = $parse(attrs.mctModel),
|
||||
unobserve = treeView.observe(expr.assign.bind(expr, scope));
|
||||
|
||||
element.append(angular.element(treeView.elements()));
|
||||
|
||||
scope.$parent.$watch(attrs.mctModel, treeView.value.bind(treeView));
|
||||
scope.$watch('mctObject', treeView.model.bind(treeView));
|
||||
scope.$on('$destroy', unobserve);
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -103,6 +103,16 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
TreeView.prototype.observe = function (callback) {
|
||||
callback(this.selectedObject);
|
||||
this.callbacks.push(callback);
|
||||
return function () {
|
||||
this.callbacks = this.callbacks.filter(function (c) {
|
||||
return c !== callback;
|
||||
});
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {HTMLElement[]}
|
||||
|
Loading…
x
Reference in New Issue
Block a user