1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-15 07:22:35 +01:00
Radarr/UI/AddSeries/Existing/CollectionView.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

2013-06-21 03:43:58 +02:00
'use strict';
define(
[
'marionette',
'AddSeries/AddSeriesView',
2013-06-21 03:43:58 +02:00
'AddSeries/Existing/UnmappedFolderCollection'
], function (Marionette, AddSeriesView, UnmappedFolderCollection) {
2013-06-21 03:43:58 +02:00
return Marionette.CollectionView.extend({
itemView: AddSeriesView,
2013-06-21 03:43:58 +02:00
initialize: function () {
this.collection = new UnmappedFolderCollection();
this.refreshItems();
},
refreshItems: function () {
this.collection.importItems(this.model);
},
showCollection: function () {
this._showAndSearch(0);
},
_showAndSearch: function (index) {
var model = this.collection.at(index);
2013-06-21 03:43:58 +02:00
if (model) {
var that = this;
var currentIndex = index;
var folderName = model.get('folder').name;
2013-06-21 03:43:58 +02:00
this.addItemView(model, this.getItemView(), index);
$.when(this.children.findByModel(model).search({term: folderName})).then(function () {
2013-06-21 03:43:58 +02:00
that._showAndSearch(currentIndex + 1);
});
}
},
itemViewOptions: {
isExisting: true
2013-06-21 03:43:58 +02:00
}
});
});