Sonarr/UI/Series/Edit/EditSeriesView.js

56 lines
1.5 KiB
JavaScript
Raw Normal View History

'use strict';
define(
[
2013-07-24 01:15:58 +00:00
'app',
'marionette',
'Series/Delete/DeleteSeriesView',
'Quality/QualityProfileCollection',
'Mixins/AsModelBoundView',
'Mixins/AutoComplete'
], function (App, Marionette, DeleteSeriesView, QualityProfiles, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template: 'Series/Edit/EditSeriesTemplate',
ui: {
qualityProfile: '.x-quality-profile',
path : '.x-path'
},
events: {
2013-07-24 01:15:58 +00:00
'click .x-save' : '_saveSeries',
'click .x-remove': '_removeSeries'
},
initialize: function () {
this.model.set('qualityProfiles', QualityProfiles);
},
2013-07-24 01:15:58 +00:00
_saveSeries: function () {
2013-07-24 01:15:58 +00:00
var self = this;
2013-07-16 23:54:45 +00:00
var qualityProfileId = this.ui.qualityProfile.val();
this.model.set({ qualityProfileId: qualityProfileId});
2013-07-24 01:15:58 +00:00
this.model.save().done(function () {
self.trigger('saved');
App.vent.trigger(App.Commands.CloseModalCommand);
});
2013-07-16 23:54:45 +00:00
},
onRender: function () {
this.ui.path.autoComplete('/directories');
},
2013-07-24 01:15:58 +00:00
_removeSeries: function () {
var view = new DeleteSeriesView({ model: this.model });
App.modalRegion.show(view);
}
});
return AsModelBoundView.apply(view);
});