1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-29 11:05:44 +00:00
Lidarr/UI/AddSeries/New/SearchResultView.js

60 lines
2 KiB
JavaScript
Raw Normal View History

'use strict';
define(['app', 'Series/SeriesCollection'], function (app) {
NzbDrone.AddSeries.New.SearchItemView = Backbone.Marionette.ItemView.extend({
2013-05-03 23:09:09 +00: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 06:25:58 +00: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-03-31 21:45:16 +00:00
this.model.set('qualityProfileId', quality);
this.model.set('rootFolderPath', rootFolderPath);
var self = this;
2013-03-31 21:45:16 +00:00
this.model.save(undefined, {
2013-05-03 23:09:09 +00:00
url : NzbDrone.Series.SeriesCollection.prototype.url,
success: function () {
2013-05-23 06:25:58 +00:00
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
NzbDrone.Shared.Messenger.show({
message: 'Added: ' + self.model.get('title')
});
2013-04-12 15:08:09 +00:00
NzbDrone.vent.trigger(NzbDrone.Events.SeriesAdded, { existing: false, series: self.model });
2013-05-23 06:25:58 +00:00
},
fail: function () {
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
}
});
}
});
NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({
2013-01-27 02:14:42 +00:00
itemView : NzbDrone.AddSeries.New.SearchItemView,
initialize: function () {
this.listenTo(this.collection, 'reset', this.render);
}
2013-02-22 06:18:36 +00:00
});
2013-01-27 02:14:42 +00:00
});