mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 09:03:49 -07:00
Add new series will clear results and re-focus search box
This commit is contained in:
parent
0ee82feab7
commit
5d8bc50c77
8 changed files with 49 additions and 40 deletions
|
@ -38,6 +38,9 @@ define(
|
|||
throw 'model is required';
|
||||
}
|
||||
|
||||
this.templateHelpers = {};
|
||||
this._configureTemplateHelpers();
|
||||
|
||||
this.listenTo(App.vent, Config.Events.ConfigUpdatedEvent, this._onConfigUpdated);
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
this.listenTo(RootFolders, 'all', this.render);
|
||||
|
@ -72,22 +75,18 @@ define(
|
|||
});
|
||||
},
|
||||
|
||||
serializeData: function () {
|
||||
var data = this.model.toJSON();
|
||||
|
||||
_configureTemplateHelpers: function () {
|
||||
var existingSeries = SeriesCollection.where({tvdbId: this.model.get('tvdbId')});
|
||||
|
||||
if (existingSeries.length > 0) {
|
||||
data.existing = existingSeries[0].toJSON();
|
||||
this.templateHelpers.existing = existingSeries[0].toJSON();
|
||||
}
|
||||
|
||||
data.qualityProfiles = QualityProfiles.toJSON();
|
||||
this.templateHelpers.qualityProfiles = QualityProfiles.toJSON();
|
||||
|
||||
if (!data.isExisting) {
|
||||
data.rootFolders = RootFolders.toJSON();
|
||||
if (!this.model.get('isExisting')) {
|
||||
this.templateHelpers.rootFolders = RootFolders.toJSON();
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
_onConfigUpdated: function (options) {
|
||||
|
@ -135,17 +134,23 @@ define(
|
|||
|
||||
SeriesCollection.add(this.model);
|
||||
|
||||
this.model.save().done(function () {
|
||||
|
||||
var promise = this.model.save();
|
||||
|
||||
promise.done(function () {
|
||||
self.close();
|
||||
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
||||
|
||||
Messenger.show({
|
||||
message: 'Added: ' + self.model.get('title')
|
||||
});
|
||||
|
||||
App.vent.trigger(App.Events.SeriesAdded, { series: self.model });
|
||||
}).fail(function () {
|
||||
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
||||
});
|
||||
});
|
||||
|
||||
promise.fail(function () {
|
||||
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue