2013-06-21 04:43:58 +03:00
|
|
|
'use strict';
|
|
|
|
define(
|
|
|
|
[
|
|
|
|
'marionette',
|
2013-06-22 03:48:23 +03:00
|
|
|
'AddSeries/AddSeriesView',
|
2013-06-21 04:43:58 +03:00
|
|
|
'AddSeries/Existing/UnmappedFolderCollection'
|
2013-06-22 03:48:23 +03:00
|
|
|
], function (Marionette, AddSeriesView, UnmappedFolderCollection) {
|
2013-06-21 04:43:58 +03:00
|
|
|
|
|
|
|
return Marionette.CollectionView.extend({
|
|
|
|
|
2013-06-22 03:48:23 +03:00
|
|
|
itemView: AddSeriesView,
|
2013-06-21 04:43:58 +03:00
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
this.collection = new UnmappedFolderCollection();
|
|
|
|
this.collection.importItems(this.model);
|
|
|
|
},
|
|
|
|
|
|
|
|
showCollection: function () {
|
|
|
|
this._showAndSearch(0);
|
|
|
|
},
|
|
|
|
|
|
|
|
_showAndSearch: function (index) {
|
2013-09-18 22:43:37 +03:00
|
|
|
var self = this;
|
2013-06-21 04:43:58 +03:00
|
|
|
var model = this.collection.at(index);
|
2013-06-22 03:48:23 +03:00
|
|
|
|
2013-06-21 04:43:58 +03:00
|
|
|
if (model) {
|
|
|
|
var currentIndex = index;
|
2013-06-22 03:48:23 +03:00
|
|
|
var folderName = model.get('folder').name;
|
2013-06-21 04:43:58 +03:00
|
|
|
this.addItemView(model, this.getItemView(), index);
|
2013-09-18 22:43:37 +03:00
|
|
|
this.children.findByModel(model)
|
|
|
|
.search({term: folderName})
|
2013-09-29 09:29:52 +03:00
|
|
|
.always(function () {
|
2013-09-29 10:02:12 +03:00
|
|
|
if (!self.isClosed) {
|
|
|
|
self._showAndSearch(currentIndex + 1);
|
|
|
|
}
|
2013-09-29 09:29:52 +03:00
|
|
|
});
|
2013-06-21 04:43:58 +03:00
|
|
|
}
|
2013-06-22 03:48:23 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
itemViewOptions: {
|
|
|
|
isExisting: true
|
2013-06-21 04:43:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|