Sonarr/UI/Settings/Notifications/EditView.js

46 lines
1.4 KiB
JavaScript
Raw Normal View History

"use strict";
define([
'app',
2013-05-29 07:20:41 +00:00
'Settings/Notifications/Model',
'Settings/Notifications/DeleteView'
], function () {
NzbDrone.Settings.Notifications.EditView = Backbone.Marionette.ItemView.extend({
template : 'Settings/Notifications/EditTemplate',
events: {
2013-05-29 07:20:41 +00:00
'click .x-save': '_saveNotification',
'click .x-remove': '_deleteNotification'
},
2013-05-29 02:49:17 +00:00
initialize: function (options) {
this.notificationCollection = options.notificationCollection;
},
2013-05-29 07:20:41 +00:00
_saveNotification: function () {
2013-05-29 02:49:17 +00:00
var name = this.model.get('name');
var success = 'Notification Saved: ' + name;
var fail = 'Failed to save notification: ' + name;
2013-06-01 00:22:47 +00:00
this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
successMessage: success,
errorMessage: fail,
successCallback: this._saveSuccess,
context: this
}));
},
2013-05-29 07:20:41 +00:00
_deleteNotification: function () {
var view = new NzbDrone.Settings.Notifications.DeleteView({ model: this.model });
NzbDrone.modalRegion.show(view);
},
2013-06-01 00:22:47 +00:00
_saveSuccess: function () {
this.notificationCollection.add(this.model, { merge: true });
NzbDrone.modalRegion.closeModal();
}
});
});