updating add existing series to use the common views.

This commit is contained in:
Keivan Beigi 2013-06-21 17:48:23 -07:00
parent 1b55859eb2
commit 3c686808f2
9 changed files with 147 additions and 84 deletions

View file

@ -2,15 +2,45 @@
define(
[
'marionette',
'AddSeries/SearchResultView'
], function (Marionette, SearchResultView) {
'AddSeries/SearchResultView',
'AddSeries/Collection'
], function (Marionette, SearchResultView, SearchResultCollection) {
return Marionette.CollectionView.extend({
itemView : SearchResultView,
initialize: function () {
this.listenTo(this.collection, 'reset', this.render);
itemView: SearchResultView,
initialize: function (options) {
this.isExisting = options.isExisting;
this.fullResult = options.fullResult;
this.listenTo(this.fullResult, 'sync', this._processResultCollection);
},
showAll: function () {
this.showingAll = true;
this.fullResult.each(function (searchResult) {
this.collection.add(searchResult);
});
this.render();
},
_processResultCollection: function () {
if (!this.showingAll && this.isExisting) {
this.collection = new SearchResultCollection();
this.collection.add(this.fullResult.shift());
}
else {
this.collection = this.fullResult;
}
}
});
});