[Tree] Begin handling selection state

This commit is contained in:
Victor Woeltjen
2016-03-11 17:00:55 -08:00
parent 4a8222a152
commit 03ab3bddc4
3 changed files with 50 additions and 4 deletions

View File

@@ -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;
});
});