Fixed up notifications edit

pull/2/head
Mark McDowall 12 years ago
parent 23695b3fe8
commit 0725dcee73

@ -1,6 +1,10 @@
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
{{#if id}}
<h3>Edit</h3> <h3>Edit</h3>
{{else}}
<h3>Add</h3>
{{/if}}
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="form-horizontal"> <div class="form-horizontal">
@ -56,7 +60,9 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
{{#if id}}
<button class="btn btn-danger pull-left x-remove">delete</button> <button class="btn btn-danger pull-left x-remove">delete</button>
{{/if}}
<button class="btn" data-dismiss="modal">cancel</button> <button class="btn" data-dismiss="modal">cancel</button>
<button class="btn btn-primary x-save">save</button> <button class="btn btn-primary x-save">save</button>
</div> </div>

@ -2,7 +2,8 @@
define([ define([
'app', 'app',
'Settings/Notifications/Model' 'Settings/Notifications/Model',
'Settings/Notifications/DeleteView'
], function () { ], function () {
@ -10,14 +11,15 @@ define([
template : 'Settings/Notifications/EditTemplate', template : 'Settings/Notifications/EditTemplate',
events: { events: {
'click .x-save': 'save' 'click .x-save': '_saveNotification',
'click .x-remove': '_deleteNotification'
}, },
initialize: function (options) { initialize: function (options) {
this.notificationCollection = options.notificationCollection; this.notificationCollection = options.notificationCollection;
}, },
save: function () { _saveNotification: function () {
var name = this.model.get('name'); var name = this.model.get('name');
var success = 'Notification Saved: ' + name; var success = 'Notification Saved: ' + name;
var fail = 'Failed to save notification: ' + name; var fail = 'Failed to save notification: ' + name;
@ -25,6 +27,11 @@ define([
this.model.save(undefined, this.syncNotification(success, fail, this)); this.model.save(undefined, this.syncNotification(success, fail, this));
}, },
_deleteNotification: function () {
var view = new NzbDrone.Settings.Notifications.DeleteView({ model: this.model });
NzbDrone.modalRegion.show(view);
},
syncNotification: function (success, error, context) { syncNotification: function (success, error, context) {
return { return {
success: function () { success: function () {

Loading…
Cancel
Save