1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/AddSeries/SearchResultCollectionView.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

2013-06-21 04:43:58 +03:00
'use strict';
define(
[
'marionette',
'AddSeries/SearchResultView',
'AddSeries/Collection'
], function (Marionette, SearchResultView, SearchResultCollection) {
2013-06-21 04:43:58 +03:00
return Marionette.CollectionView.extend({
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;
}
2013-06-21 04:43:58 +03:00
}
2013-06-21 04:43:58 +03:00
});
});