1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/AddSeries/New/SearchResultView.js

60 lines
2.0 KiB
JavaScript
Raw Normal View History

'use strict';
define(['app', 'Series/SeriesCollection'], function (app) {
NzbDrone.AddSeries.New.SearchItemView = Backbone.Marionette.ItemView.extend({
2013-05-04 02:09:09 +03:00
template: "AddSeries/SearchResultTemplate",
ui: {
qualityProfile: '.x-quality-profile',
rootFolder : '.x-root-folder',
addButton : '.x-add'
},
events: {
'click .x-add': 'addSeries'
},
onRender: function () {
this.listenTo(this.model, 'change', this.render);
},
addSeries: function () {
2013-05-23 09:25:58 +03:00
var icon = this.ui.addButton.find('icon');
icon.removeClass('icon-plus').addClass('icon-spin icon-spinner disabled');
var quality = this.ui.qualityProfile.val();
var rootFolderPath = this.ui.rootFolder.children(':selected').text();
2013-04-01 00:45:16 +03:00
this.model.set('qualityProfileId', quality);
this.model.set('rootFolderPath', rootFolderPath);
var self = this;
2013-04-01 00:45:16 +03:00
this.model.save(undefined, {
2013-05-04 02:09:09 +03:00
url : NzbDrone.Series.SeriesCollection.prototype.url,
success: function () {
2013-05-23 09:25:58 +03:00
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
NzbDrone.Shared.Messenger.show({
message: 'Added: ' + self.model.get('title')
});
2013-04-12 18:08:09 +03:00
NzbDrone.vent.trigger(NzbDrone.Events.SeriesAdded, { existing: false, series: self.model });
2013-05-23 09:25:58 +03:00
},
fail: function () {
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
}
});
}
});
NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({
2013-01-27 05:14:42 +03:00
itemView : NzbDrone.AddSeries.New.SearchItemView,
initialize: function () {
this.listenTo(this.collection, 'reset', this.render);
}
2013-02-22 09:18:36 +03:00
});
2013-01-27 05:14:42 +03:00
});