Validate newznab indexers when adding

This commit is contained in:
Mark McDowall 2013-09-25 19:51:07 -07:00
commit f0e721ee80
8 changed files with 87 additions and 6 deletions

View file

@ -39,6 +39,9 @@
{{#if id}}
<button class="btn btn-danger pull-left x-remove">delete</button>
{{/if}}
<span class="x-activity"></span>
<button class="btn" data-dismiss="modal">cancel</button>
<div class="btn-group">

View file

@ -11,6 +11,10 @@ define(
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/EditTemplate',
ui : {
activity: '.x-activity'
},
events: {
'click .x-save' : '_save',
'click .x-save-and-add': '_saveAndAdd'
@ -21,6 +25,8 @@ define(
},
_save: function () {
this.ui.activity.html('<i class="icon-nd-spinner"></i>');
var self = this;
var promise = this.model.saveSettings();
@ -29,10 +35,16 @@ define(
self.indexerCollection.add(self.model, { merge: true });
App.vent.trigger(App.Commands.CloseModalCommand);
});
promise.always(function () {
self.ui.activity.empty();
});
}
},
_saveAndAdd: function () {
this.ui.activity.html('<i class="icon-nd-spinner"></i>');
var self = this;
var promise = this.model.saveSettings();
@ -50,6 +62,10 @@ define(
self.model.set('fields.' + key + '.value', '');
});
});
promise.always(function () {
self.ui.activity.empty();
});
}
}
});