[API] Use selection state from toolbar (#1070)

* [API] Allow selection

* [API] Keep in sync using model

* [API] Add selection as EventEmitter

* [API] Use selection from ToDo tutorial

* [API] Restore selection functionality
This commit is contained in:
Victor Woeltjen
2016-07-22 13:56:45 -07:00
committed by Pete Richards
parent d5aa998b4c
commit 95ef70a24c

View File

@ -58,8 +58,11 @@ define([
$(container).empty().append(self.$els); $(container).empty().append(self.$els);
self.initialize(); self.initialize();
self.objectChanged(object) self.objectChanged(object);
mct.selection.on('change', self.render);
}); });
}; };
@ -67,6 +70,7 @@ define([
if (this.mutableObject) { if (this.mutableObject) {
this.mutableObject.stopListening(); this.mutableObject.stopListening();
} }
mct.selection.off('change', this.render);
}; };
TodoView.prototype.setFilter = function (value) { TodoView.prototype.setFilter = function (value) {
@ -78,8 +82,6 @@ define([
Object.keys(this.$buttons).forEach(function (k) { Object.keys(this.$buttons).forEach(function (k) {
this.$buttons[k].on('click', this.setFilter.bind(this, k)); this.$buttons[k].on('click', this.setFilter.bind(this, k));
}, this); }, this);
mct.selection.on('change', this.render);
}; };
TodoView.prototype.render = function () { TodoView.prototype.render = function () {
@ -139,7 +141,6 @@ define([
function TodoToolbarView(domainObject) { function TodoToolbarView(domainObject) {
this.domainObject = domainObject; this.domainObject = domainObject;
this.mutableObject = undefined; this.mutableObject = undefined;
this.handleSelectionChange = this.handleSelectionChange.bind(this); this.handleSelectionChange = this.handleSelectionChange.bind(this);
} }