Sonarr/UI/AddSeries/New/SearchResultView.js

56 lines
1.7 KiB
JavaScript
Raw Normal View History

'use strict';
define(['app', 'Shared/NotificationCollection', 'Series/SeriesCollection'], function (app, notificationCollection) {
NzbDrone.AddSeries.New.SearchItemView = Backbone.Marionette.ItemView.extend({
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 04:30:51 +00:00
var rootFolderId = this.ui.rootFolder.val();
2013-03-31 21:45:16 +00:00
this.model.set('qualityProfileId', quality);
2013-04-11 04:30:51 +00:00
this.model.set('rootFolderId', rootFolderId);
var self = this;
2013-03-31 21:45:16 +00:00
this.model.save(undefined, {
success: function () {
var notificationModel = new NzbDrone.Shared.NotificationModel({
title : 'Added',
2013-03-31 21:45:16 +00:00
message: self.model.get('title'),
level : 'success'
});
notificationCollection.push(notificationModel);
2013-04-12 15:08:09 +00:00
NzbDrone.vent.trigger(NzbDrone.Events.SeriesAdded, { existing: false, series: self.model });
}
});
}
});
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
});