2013-07-14 09:05:51 +03:00
|
|
|
'use strict';
|
2013-06-25 02:41:59 +03:00
|
|
|
define(
|
|
|
|
[
|
2013-07-24 04:15:58 +03:00
|
|
|
'app',
|
2013-06-25 02:41:59 +03:00
|
|
|
'marionette',
|
|
|
|
'Quality/QualityProfileCollection',
|
2013-07-14 09:05:51 +03:00
|
|
|
'Mixins/AsModelBoundView',
|
2013-08-22 03:36:35 +03:00
|
|
|
'Mixins/AsValidatedView',
|
2013-07-14 09:05:51 +03:00
|
|
|
'Mixins/AutoComplete'
|
2013-08-22 03:36:35 +03:00
|
|
|
], function (App, Marionette, QualityProfiles, AsModelBoundView, AsValidatedView) {
|
2013-06-25 02:41:59 +03:00
|
|
|
|
|
|
|
var view = Marionette.ItemView.extend({
|
|
|
|
template: 'Series/Edit/EditSeriesTemplate',
|
|
|
|
|
|
|
|
ui: {
|
2013-07-14 09:05:51 +03:00
|
|
|
qualityProfile: '.x-quality-profile',
|
|
|
|
path : '.x-path'
|
2013-06-25 02:41:59 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
2013-07-24 04:15:58 +03:00
|
|
|
'click .x-save' : '_saveSeries',
|
|
|
|
'click .x-remove': '_removeSeries'
|
2013-06-25 02:41:59 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
this.model.set('qualityProfiles', QualityProfiles);
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2013-07-24 04:15:58 +03:00
|
|
|
_saveSeries: function () {
|
2013-06-25 02:41:59 +03:00
|
|
|
|
2013-07-24 04:15:58 +03:00
|
|
|
var self = this;
|
2013-07-17 02:54:45 +03:00
|
|
|
var qualityProfileId = this.ui.qualityProfile.val();
|
|
|
|
this.model.set({ qualityProfileId: qualityProfileId});
|
2013-06-25 02:41:59 +03:00
|
|
|
|
2013-07-24 04:15:58 +03:00
|
|
|
this.model.save().done(function () {
|
|
|
|
self.trigger('saved');
|
|
|
|
App.vent.trigger(App.Commands.CloseModalCommand);
|
|
|
|
});
|
2013-07-17 02:54:45 +03:00
|
|
|
},
|
2013-07-14 09:05:51 +03:00
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
this.ui.path.autoComplete('/directories');
|
|
|
|
},
|
|
|
|
|
2013-07-24 04:15:58 +03:00
|
|
|
_removeSeries: function () {
|
2013-07-24 07:16:52 +03:00
|
|
|
App.vent.trigger(App.Commands.DeleteSeriesCommand, {series:this.model});
|
2013-06-25 02:41:59 +03:00
|
|
|
}
|
|
|
|
});
|
2013-07-14 09:05:51 +03:00
|
|
|
|
|
|
|
|
2013-08-22 03:36:35 +03:00
|
|
|
AsModelBoundView.apply(view);
|
|
|
|
return AsValidatedView.apply(view);
|
2013-02-14 21:01:30 +03:00
|
|
|
});
|