2013-05-21 06:16:19 +00:00
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
define([
|
|
|
|
|
'app',
|
|
|
|
|
'Settings/Notifications/Model'
|
|
|
|
|
|
|
|
|
|
], function () {
|
|
|
|
|
|
|
|
|
|
NzbDrone.Settings.Notifications.EditView = Backbone.Marionette.ItemView.extend({
|
|
|
|
|
template : 'Settings/Notifications/EditTemplate',
|
|
|
|
|
|
|
|
|
|
events: {
|
|
|
|
|
'click .x-save': 'save'
|
|
|
|
|
},
|
|
|
|
|
|
2013-05-29 02:49:17 +00:00
|
|
|
|
initialize: function (options) {
|
|
|
|
|
this.notificationCollection = options.notificationCollection;
|
|
|
|
|
},
|
|
|
|
|
|
2013-05-21 06:16:19 +00:00
|
|
|
|
save: 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-05-21 06:16:19 +00:00
|
|
|
|
|
2013-05-29 02:49:17 +00:00
|
|
|
|
this.model.save(undefined, this.syncNotification(success, fail, this));
|
2013-05-21 06:16:19 +00:00
|
|
|
|
},
|
|
|
|
|
|
2013-05-29 02:49:17 +00:00
|
|
|
|
syncNotification: function (success, error, context) {
|
2013-05-21 06:16:19 +00:00
|
|
|
|
return {
|
|
|
|
|
success: function () {
|
2013-05-29 02:49:17 +00:00
|
|
|
|
NzbDrone.Shared.Messenger.show({
|
|
|
|
|
message: success
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
context.notificationCollection.add(context.model, { merge: true });
|
2013-05-29 06:24:45 +00:00
|
|
|
|
NzbDrone.modalRegion.closeModal();
|
2013-05-21 06:16:19 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
error: function () {
|
|
|
|
|
window.alert(error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|