Sonarr/UI/Settings/Indexers/EditView.js

58 lines
1.7 KiB
JavaScript
Raw Normal View History

'use strict';
2013-05-28 00:19:07 +00:00
define(
[
2013-06-28 01:55:45 +00:00
'app',
'marionette',
'Mixins/AsModelBoundView'
2013-06-28 01:55:45 +00:00
], function (App, Marionette, AsModelBoundView) {
2013-05-28 00:19:07 +00:00
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/EditTemplate',
2013-05-28 00:19:07 +00:00
events: {
2013-06-28 01:55:45 +00:00
'click .x-save': '_save',
'click .x-save-and-add': '_saveAndAdd'
},
2013-05-28 00:19:07 +00:00
initialize: function (options) {
this.indexerCollection = options.indexerCollection;
},
2013-05-28 00:19:07 +00:00
2013-06-28 01:55:45 +00:00
_save: function () {
var self = this;
var promise = this.model.saveSettings();
if (promise) {
promise.done(function () {
self.indexerCollection.add(self.model, { merge: true });
App.modalRegion.closeModal();
});
}
},
_saveAndAdd: function () {
var self = this;
var promise = this.model.saveSettings();
if (promise) {
promise.done(function () {
self.indexerCollection.add(self.model, { merge: true });
self.model.set({
id: undefined,
name: '',
enable: false
});
_.each(self.model.get('fields'), function (value, key, list) {
self.model.set('fields.' + key +'.value', '');
});
});
}
}
});
2013-06-19 01:02:23 +00:00
return AsModelBoundView.call(view);
});