[Tree] Begin handling selection state
This commit is contained in:
@@ -30,6 +30,7 @@ define([
|
||||
function TreeView() {
|
||||
this.ul = $('<ul class="tree"></ul>');
|
||||
this.nodeViews = [];
|
||||
this.callbacks = [];
|
||||
}
|
||||
|
||||
function newTreeView() {
|
||||
@@ -62,6 +63,7 @@ define([
|
||||
if (domainObject === self.activeObject) {
|
||||
self.setSize(domainObjects.length);
|
||||
domainObjects.forEach(addNode);
|
||||
self.updateNodeViewSelection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +89,20 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
TreeView.prototype.updateNodeViewSelection = function () {
|
||||
this.nodeViews.forEach(function (nodeView) {
|
||||
nodeView.value(this.selectedObject);
|
||||
});
|
||||
};
|
||||
|
||||
TreeView.prototype.value = function (domainObject) {
|
||||
this.selectedObject = domainObject;
|
||||
this.updateNodeViewSelection();
|
||||
this.callbacks.forEach(function (callback) {
|
||||
callback(domainObject);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {HTMLElement[]}
|
||||
@@ -97,4 +113,4 @@ define([
|
||||
|
||||
|
||||
return TreeView;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user