mirror of
https://github.com/nasa/openmct.git
synced 2025-06-16 06:08:11 +00:00
[Tree] Begin wiring in selection
This commit is contained in:
@ -19,6 +19,6 @@
|
|||||||
this source code distribution or the Licensing information page available
|
this source code distribution or the Licensing information page available
|
||||||
at runtime from the About dialog for additional information.
|
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>
|
</mct-tree>
|
||||||
|
|
||||||
|
@ -25,13 +25,17 @@ define([
|
|||||||
'angular',
|
'angular',
|
||||||
'../ui/TreeView'
|
'../ui/TreeView'
|
||||||
], function (angular, TreeView) {
|
], function (angular, TreeView) {
|
||||||
function MCTTree() {
|
function MCTTree($parse) {
|
||||||
function link(scope, element) {
|
function link(scope, element, attrs) {
|
||||||
var treeView = new TreeView();
|
var treeView = new TreeView(),
|
||||||
|
expr = $parse(attrs.mctModel),
|
||||||
|
unobserve = treeView.observe(expr.assign.bind(expr, scope));
|
||||||
|
|
||||||
element.append(angular.element(treeView.elements()));
|
element.append(angular.element(treeView.elements()));
|
||||||
|
|
||||||
|
scope.$parent.$watch(attrs.mctModel, treeView.value.bind(treeView));
|
||||||
scope.$watch('mctObject', treeView.model.bind(treeView));
|
scope.$watch('mctObject', treeView.model.bind(treeView));
|
||||||
|
scope.$on('$destroy', unobserve);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
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[]}
|
* @returns {HTMLElement[]}
|
||||||
|
Reference in New Issue
Block a user