mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 17:13:49 -07:00
updating add existing series to use the common views.
This commit is contained in:
parent
1b55859eb2
commit
3c686808f2
9 changed files with 147 additions and 84 deletions
|
@ -1,5 +1,5 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-prepend nz-input-large add-series-search span11">
|
<div class="input-prepend nz-input-large add-series-search span11 x-search-bar">
|
||||||
<i class="add-on icon-search"/>
|
<i class="add-on icon-search"/>
|
||||||
<input type="text" class="input-block-level x-series-search" placeholder="Start typing the name of series you want to add ...">
|
<input type="text" class="input-block-level x-series-search" placeholder="Start typing the name of series you want to add ...">
|
||||||
</div>
|
</div>
|
||||||
|
@ -7,3 +7,6 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div id="search-result" class="result-list span12"/>
|
<div id="search-result" class="result-list span12"/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="text-center new-series-loadmore x-load-more" style="display: none;">
|
||||||
|
<i class="icon-angle-down"/> more
|
||||||
|
</div>
|
||||||
|
|
|
@ -14,15 +14,18 @@ define(
|
||||||
template: 'AddSeries/AddSeriesTemplate',
|
template: 'AddSeries/AddSeriesTemplate',
|
||||||
|
|
||||||
ui: {
|
ui: {
|
||||||
seriesSearch: '.x-series-search'
|
seriesSearch: '.x-series-search',
|
||||||
|
searchBar : '.x-search-bar',
|
||||||
|
loadMore : '.x-load-more'
|
||||||
},
|
},
|
||||||
|
|
||||||
regions: {
|
regions: {
|
||||||
searchResult: '#search-result'
|
searchResult: '#search-result'
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function (options) {
|
||||||
this.collection = new AddSeriesCollection();
|
this.collection = new AddSeriesCollection();
|
||||||
|
this.isExisting = options.isExisting;
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender: function () {
|
onRender: function () {
|
||||||
|
@ -30,31 +33,45 @@ define(
|
||||||
|
|
||||||
this.ui.seriesSearch.data('timeout', null).keyup(function () {
|
this.ui.seriesSearch.data('timeout', null).keyup(function () {
|
||||||
window.clearTimeout(self.$el.data('timeout'));
|
window.clearTimeout(self.$el.data('timeout'));
|
||||||
self.$el.data('timeout', window.setTimeout(self.search, 500, self));
|
self.$el.data('timeout', window.setTimeout(function () {
|
||||||
|
self.search.call(self, {
|
||||||
|
term: self.ui.seriesSearch.val()
|
||||||
|
});
|
||||||
|
}, 500));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.resultView = new SearchResultCollectionView({ collection: this.collection });
|
if (this.isExisting) {
|
||||||
|
this.ui.searchBar.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resultView = new SearchResultCollectionView({
|
||||||
|
fullResult: this.collection,
|
||||||
|
isExisting: this.isExisting
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
search: function (context) {
|
search: function (options) {
|
||||||
|
|
||||||
context.abortExistingRequest();
|
var self = this;
|
||||||
|
|
||||||
var term = context.ui.seriesSearch.val();
|
this.abortExistingRequest();
|
||||||
context.collection.reset();
|
|
||||||
|
|
||||||
if (term === '') {
|
this.collection.reset();
|
||||||
context.searchResult.close();
|
|
||||||
|
if (!options || options.term === '') {
|
||||||
|
this.searchResult.close();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
context.searchResult.show(new SpinnerView());
|
this.searchResult.show(new SpinnerView());
|
||||||
|
this.currentSearchRequest = this.collection.fetch({
|
||||||
|
data: { term: options.term }
|
||||||
|
}).done(function () {
|
||||||
|
self.searchResult.show(self.resultView);
|
||||||
|
|
||||||
context.currentSearchRequest = context.collection.fetch({
|
if (!self.showingAll && self.isExisting) {
|
||||||
data : { term: term },
|
self.ui.loadMore.show();
|
||||||
success: function () {
|
}
|
||||||
context.searchResult.show(context.resultView);
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
define(
|
define(
|
||||||
[
|
[
|
||||||
'marionette',
|
'marionette',
|
||||||
'AddSeries/Existing/CompositeView',
|
'AddSeries/AddSeriesView',
|
||||||
'AddSeries/Existing/UnmappedFolderCollection'
|
'AddSeries/Existing/UnmappedFolderCollection'
|
||||||
], function (Marionette, UnmappedFolderCompositeView, UnmappedFolderCollection) {
|
], function (Marionette, AddSeriesView, UnmappedFolderCollection) {
|
||||||
|
|
||||||
return Marionette.CollectionView.extend({
|
return Marionette.CollectionView.extend({
|
||||||
|
|
||||||
itemView: UnmappedFolderCompositeView,
|
itemView: AddSeriesView,
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.collection = new UnmappedFolderCollection();
|
this.collection = new UnmappedFolderCollection();
|
||||||
|
@ -26,14 +26,20 @@ define(
|
||||||
_showAndSearch: function (index) {
|
_showAndSearch: function (index) {
|
||||||
|
|
||||||
var model = this.collection.at(index);
|
var model = this.collection.at(index);
|
||||||
|
|
||||||
if (model) {
|
if (model) {
|
||||||
var that = this;
|
var that = this;
|
||||||
var currentIndex = index;
|
var currentIndex = index;
|
||||||
|
var folderName = model.get('folder').name;
|
||||||
this.addItemView(model, this.getItemView(), index);
|
this.addItemView(model, this.getItemView(), index);
|
||||||
$.when(this.children.findByModel(model).search()).then(function () {
|
$.when(this.children.findByModel(model).search({term: folderName})).then(function () {
|
||||||
that._showAndSearch(currentIndex + 1);
|
that._showAndSearch(currentIndex + 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
itemViewOptions: {
|
||||||
|
isExisting: true
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,5 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="x-folder-name-match-results folder-name-matches"/>
|
<div class="x-folder-name-match-results folder-name-matches"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center new-series-loadmore x-load-more" style="display: none;">
|
|
||||||
<i class="icon-angle-down"/> more
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,7 +17,6 @@ define(
|
||||||
|
|
||||||
removeFolder: function () {
|
removeFolder: function () {
|
||||||
this.model.destroy({ wait: true });
|
this.model.destroy({ wait: true });
|
||||||
this.model.collection.remove(this.model);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
folderSelected: function () {
|
folderSelected: function () {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<td name="path" class="span10 x-folder clickable"/>
|
<td class="span10 x-folder clickable">
|
||||||
|
{{path}}
|
||||||
|
</td>
|
||||||
<td class="span3 x-folder clickable">
|
<td class="span3 x-folder clickable">
|
||||||
<span name="freeSpaceString"></span>
|
<span>{{freeSpaceString}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="span1 nz-row-action">
|
<td class="span1 nz-row-action">
|
||||||
<div class="btn btn-danger icon-minus x-remove">
|
<div class="btn btn-danger icon-minus x-remove">
|
||||||
|
|
|
@ -2,15 +2,45 @@
|
||||||
define(
|
define(
|
||||||
[
|
[
|
||||||
'marionette',
|
'marionette',
|
||||||
'AddSeries/SearchResultView'
|
'AddSeries/SearchResultView',
|
||||||
], function (Marionette, SearchResultView) {
|
'AddSeries/Collection'
|
||||||
|
|
||||||
|
], function (Marionette, SearchResultView, SearchResultCollection) {
|
||||||
|
|
||||||
return Marionette.CollectionView.extend({
|
return Marionette.CollectionView.extend({
|
||||||
|
|
||||||
itemView : SearchResultView,
|
itemView: SearchResultView,
|
||||||
initialize: function () {
|
|
||||||
this.listenTo(this.collection, 'reset', this.render);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
define(['app', 'Series/SeriesModel'], function () {
|
define(
|
||||||
|
[
|
||||||
|
'app',
|
||||||
|
'Series/SeriesModel'
|
||||||
|
], function () {
|
||||||
|
|
||||||
NzbDrone.Series.Delete.DeleteSeriesView = Backbone.Marionette.ItemView.extend({
|
NzbDrone.Series.Delete.DeleteSeriesView = Backbone.Marionette.ItemView.extend({
|
||||||
template: 'Series/Delete/DeleteSeriesTemplate',
|
template: 'Series/Delete/DeleteSeriesTemplate',
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .x-confirm-delete': 'removeSeries'
|
'click .x-confirm-delete': 'removeSeries'
|
||||||
},
|
},
|
||||||
|
|
||||||
ui: {
|
ui: {
|
||||||
deleteFiles: '.x-delete-files'
|
deleteFiles: '.x-delete-files'
|
||||||
},
|
},
|
||||||
|
|
||||||
removeSeries: function () {
|
removeSeries: function () {
|
||||||
|
|
||||||
var deleteFiles = this.ui.deleteFiles.prop('checked');
|
var deleteFiles = this.ui.deleteFiles.prop('checked');
|
||||||
|
|
||||||
this.model.destroy({
|
this.model.destroy({
|
||||||
data : { 'deleteFiles': deleteFiles },
|
data: { 'deleteFiles': deleteFiles },
|
||||||
wait : true,
|
wait: true
|
||||||
success: function (model) {
|
}).done(function () {
|
||||||
model.collection.remove(model);
|
NzbDrone.modalRegion.close();
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
NzbDrone.modalRegion.close();
|
return NzbDrone.Series.Delete.DeleteSeriesView;
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return NzbDrone.Series.Delete.DeleteSeriesView;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,36 +1,44 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
define(['marionette', 'bootstrap'], function (Marionette) {
|
define(
|
||||||
return Marionette.Region.extend({
|
[
|
||||||
el: "#modal-region",
|
'marionette',
|
||||||
|
'bootstrap'
|
||||||
|
], function (Marionette) {
|
||||||
|
return Marionette.Region.extend({
|
||||||
|
el: "#modal-region",
|
||||||
|
|
||||||
constructor: function () {
|
constructor: function () {
|
||||||
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
|
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
|
||||||
this.on("show", this.showModal, this);
|
this.on("show", this.showModal, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
getEl: function (selector) {
|
getEl: function (selector) {
|
||||||
var $el = $(selector);
|
var $el = $(selector);
|
||||||
$el.on("hidden", this.close);
|
$el.on("hidden", this.close);
|
||||||
return $el;
|
return $el;
|
||||||
},
|
},
|
||||||
|
|
||||||
showModal: function () {
|
showModal: function () {
|
||||||
this.$el.addClass('modal hide fade');
|
this.$el.addClass('modal hide fade');
|
||||||
|
|
||||||
//need tab index so close on escape works
|
//need tab index so close on escape works
|
||||||
//https://github.com/twitter/bootstrap/issues/4663
|
//https://github.com/twitter/bootstrap/issues/4663
|
||||||
this.$el.attr('tabindex', '-1');
|
this.$el.attr('tabindex', '-1');
|
||||||
this.$el.modal({
|
this.$el.modal({
|
||||||
'show' : true,
|
'show' : true,
|
||||||
'keyboard': true,
|
'keyboard': true,
|
||||||
'backdrop': 'static'});
|
'backdrop': 'static'});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
closeModal: function () {
|
onClose: function(){
|
||||||
this.$el.modal('hide');
|
this.closeModal();
|
||||||
this.close();
|
},
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
closeModal: function () {
|
||||||
|
this.$el.modal('hide');
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue