Lidarr/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',
'Quality/QualityProfileCollection',
'Mixins/AsModelBoundView',
2013-08-22 00:36:35 +00:00
'Mixins/AsValidatedView',
'Mixins/AutoComplete'
2013-08-22 00:36:35 +00:00
], function (App, Marionette, QualityProfiles, AsModelBoundView, AsValidatedView) {
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 () {
App.vent.trigger(App.Commands.DeleteSeriesCommand, {series:this.model});
}
});
2013-08-22 00:36:35 +00:00
AsModelBoundView.apply(view);
return AsValidatedView.apply(view);
});