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

54 lines
1.5 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 () {
var quality = this.ui.qualityProfile.val();
2013-04-11 07:30:51 +03:00
var rootFolderId = this.ui.rootFolder.val();
2013-04-01 00:45:16 +03:00
this.model.set('qualityProfileId', quality);
2013-04-11 07:30:51 +03:00
this.model.set('rootFolderId', rootFolderId);
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 () {
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 });
}
});
}
});
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
});