mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
broken
This commit is contained in:
parent
0916c8b8d1
commit
24c77b4047
29 changed files with 610 additions and 517 deletions
40
UI/AddSeries/Existing/CollectionView.js
Normal file
40
UI/AddSeries/Existing/CollectionView.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'AddSeries/Existing/CompositeView',
|
||||
'AddSeries/Existing/UnmappedFolderCollection'
|
||||
], function (Marionette, UnmappedFolderCompositeView, UnmappedFolderCollection) {
|
||||
|
||||
return Marionette.CollectionView.extend({
|
||||
|
||||
itemView: UnmappedFolderCompositeView,
|
||||
|
||||
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);
|
||||
if (model) {
|
||||
var that = this;
|
||||
var currentIndex = index;
|
||||
this.addItemView(model, this.getItemView(), index);
|
||||
$.when(this.children.findByModel(model).search()).then(function () {
|
||||
that._showAndSearch(currentIndex + 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
106
UI/AddSeries/Existing/CompositeView.js
Normal file
106
UI/AddSeries/Existing/CompositeView.js
Normal file
|
@ -0,0 +1,106 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'AddSeries/Collection',
|
||||
'AddSeries/SearchResultView'
|
||||
], function (Marionette, AddSeriesCollection, SearchResultView) {
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
|
||||
template : 'AddSeries/Existing/UnmappedFolderCompositeViewTemplate',
|
||||
itemViewContainer: '.x-folder-name-match-results',
|
||||
itemView : SearchResultView,
|
||||
|
||||
events: {
|
||||
'click .x-btn-search' : 'search',
|
||||
'click .x-load-more' : '_loadMore',
|
||||
'keydown .x-txt-search': 'keyDown'
|
||||
},
|
||||
|
||||
ui: {
|
||||
searchButton: '.x-btn-search',
|
||||
searchText : '.x-txt-search',
|
||||
searchBar : '.x-search-bar',
|
||||
loadMore : '.x-load-more'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new AddSeriesCollection();
|
||||
|
||||
this.on("item:removed", function () {
|
||||
this.close();
|
||||
}, this);
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this.ui.loadMore.show();
|
||||
},
|
||||
|
||||
search: function () {
|
||||
var icon = this.ui.searchButton.find('icon');
|
||||
icon.removeClass('icon-search').addClass('icon-spin icon-spinner disabled');
|
||||
|
||||
var self = this;
|
||||
var deferred = $.Deferred();
|
||||
|
||||
this.collection.reset();
|
||||
|
||||
this.searchCollection = new AddSeriesCollection();
|
||||
|
||||
this.searchCollection.fetch({
|
||||
data : { term: this.ui.searchText.val() },
|
||||
success: function () {
|
||||
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
||||
deferred.resolve();
|
||||
self.collection.add(self.searchCollection.shift());
|
||||
|
||||
if (self.showall) {
|
||||
self._showAll();
|
||||
}
|
||||
|
||||
},
|
||||
fail : function () {
|
||||
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
||||
deferred.reject();
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
},
|
||||
|
||||
|
||||
keyDown: function (e) {
|
||||
//Check for enter being pressed
|
||||
var code = (e.keyCode ? e.keyCode :e.which);
|
||||
if (code === 13) {
|
||||
this.search();
|
||||
}
|
||||
},
|
||||
|
||||
_loadMore: function () {
|
||||
this.showall = true;
|
||||
|
||||
this.ui.searchBar.fadeIn();
|
||||
this.ui.loadMore.fadeOut();
|
||||
|
||||
this._showAll();
|
||||
},
|
||||
|
||||
_showAll: function () {
|
||||
var self = this;
|
||||
this.searchCollection.each(function (searchResult) {
|
||||
self.collection.add(searchResult);
|
||||
});
|
||||
},
|
||||
|
||||
itemViewOptions: function () {
|
||||
return {
|
||||
rootFolder: this.model.get('rootFolder'),
|
||||
folder : this.model.get('folder').path,
|
||||
isExisting: true
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
});
|
|
@ -1,139 +0,0 @@
|
|||
'use strict';
|
||||
define([
|
||||
'app', 'AddSeries/RootFolders/RootFolderCollection',
|
||||
'AddSeries/Existing/UnmappedFolderModel',
|
||||
'AddSeries/Collection',
|
||||
'AddSeries/SearchResultView',
|
||||
'Series/SeriesModel'], function () {
|
||||
|
||||
NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView = Backbone.Marionette.CompositeView.extend({
|
||||
|
||||
template : 'AddSeries/Existing/UnmappedFolderCompositeViewTemplate',
|
||||
itemViewContainer: '.x-folder-name-match-results',
|
||||
itemView : NzbDrone.AddSeries.SearchResultView,
|
||||
|
||||
events: {
|
||||
'click .x-btn-search' : 'search',
|
||||
'click .x-load-more' : '_loadMore',
|
||||
'keydown .x-txt-search': 'keyDown'
|
||||
},
|
||||
|
||||
ui: {
|
||||
searchButton: '.x-btn-search',
|
||||
searchText : '.x-txt-search',
|
||||
searchBar : '.x-search-bar',
|
||||
loadMore : '.x-load-more'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new NzbDrone.AddSeries.Collection();
|
||||
this.collection.bind('reset', this.collectionReset, this);
|
||||
|
||||
this.on("item:removed", function () {
|
||||
this.close();
|
||||
}, this);
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this.ui.loadMore.show();
|
||||
},
|
||||
|
||||
search: function () {
|
||||
var icon = this.ui.searchButton.find('icon');
|
||||
icon.removeClass('icon-search').addClass('icon-spin icon-spinner disabled');
|
||||
|
||||
var self = this;
|
||||
var deferred = $.Deferred();
|
||||
|
||||
this.collection.reset();
|
||||
|
||||
this.searchCollection = new NzbDrone.AddSeries.Collection();
|
||||
|
||||
this.searchCollection.fetch({
|
||||
data : { term: this.ui.searchText.val() },
|
||||
success: function () {
|
||||
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
||||
deferred.resolve();
|
||||
self.collection.add(self.searchCollection.shift());
|
||||
|
||||
if (self.showall) {
|
||||
self._showAll();
|
||||
}
|
||||
|
||||
},
|
||||
fail : function () {
|
||||
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
||||
deferred.reject();
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
},
|
||||
|
||||
|
||||
keyDown: function (e) {
|
||||
//Check for enter being pressed
|
||||
var code = (e.keyCode ? e.keyCode :e.which);
|
||||
if (code === 13) {
|
||||
this.search();
|
||||
}
|
||||
},
|
||||
|
||||
_loadMore: function () {
|
||||
this.showall = true;
|
||||
|
||||
this.ui.searchBar.fadeIn();
|
||||
this.ui.loadMore.fadeOut();
|
||||
|
||||
this._showAll();
|
||||
},
|
||||
|
||||
_showAll: function () {
|
||||
var self = this;
|
||||
this.searchCollection.each(function (searchResult) {
|
||||
self.collection.add(searchResult);
|
||||
});
|
||||
},
|
||||
|
||||
itemViewOptions: function () {
|
||||
return {
|
||||
rootFolder : this.model.get('rootFolder'),
|
||||
folder : this.model.get('folder').path,
|
||||
isExisting : true
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
NzbDrone.AddSeries.Existing.ListView = Backbone.Marionette.CollectionView.extend({
|
||||
|
||||
itemView: NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView,
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new NzbDrone.AddSeries.Existing.UnmappedFolderCollection();
|
||||
this.refreshItems();
|
||||
},
|
||||
|
||||
refreshItems: function () {
|
||||
this.collection.importItems(this.model);
|
||||
},
|
||||
|
||||
showCollection: function () {
|
||||
this.showAndSearch(0);
|
||||
},
|
||||
|
||||
showAndSearch: function (index) {
|
||||
|
||||
var model = this.collection.at(index);
|
||||
if (model) {
|
||||
var that = this;
|
||||
var currentIndex = index;
|
||||
this.addItemView(model, this.getItemView(), index);
|
||||
$.when(this.children.findByModel(model).search())
|
||||
.then(function () {
|
||||
that.showAndSearch(currentIndex + 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
23
UI/AddSeries/Existing/UnmappedFolderCollection.js
Normal file
23
UI/AddSeries/Existing/UnmappedFolderCollection.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'AddSeries/Existing/UnmappedFolderModel'
|
||||
], function (Backbone, UnmappedFolderModel) {
|
||||
return Backbone.Collection.extend({
|
||||
model: UnmappedFolderModel,
|
||||
|
||||
importItems: function (rootFolderModel) {
|
||||
|
||||
this.reset();
|
||||
var rootFolder = rootFolderModel;
|
||||
|
||||
_.each(rootFolderModel.get('unmappedFolders'), function (folder) {
|
||||
this.push(new UnmappedFolderModel({
|
||||
rootFolder: rootFolder,
|
||||
folder : folder
|
||||
}));
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,21 +1,10 @@
|
|||
'use strict';
|
||||
define(['app'], function () {
|
||||
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
|
||||
NzbDrone.AddSeries.Existing.UnmappedFolderModel = Backbone.Model.extend({
|
||||
});
|
||||
});
|
||||
|
||||
NzbDrone.AddSeries.Existing.UnmappedFolderCollection = Backbone.Collection.extend({
|
||||
model: NzbDrone.AddSeries.Existing.UnmappedFolderModel,
|
||||
|
||||
importItems: function (rootFolderModel) {
|
||||
|
||||
this.reset();
|
||||
var rootFolder = rootFolderModel;//.get('path');
|
||||
|
||||
_.each(rootFolderModel.get('unmappedFolders'), function (folder) {
|
||||
this.push(new NzbDrone.AddSeries.Existing.UnmappedFolderModel({ rootFolder: rootFolder, folder: folder}));
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue