mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-12 16:13:58 -07:00
Fixed: Error messages not being shown in the UI or being shown in the wrong place
This commit is contained in:
parent
9916479f02
commit
545bc756f2
13 changed files with 66 additions and 34 deletions
|
@ -12,19 +12,12 @@ define(
|
|||
var originalBeforeClose = this.prototype.onBeforeClose;
|
||||
|
||||
var errorHandler = function (response) {
|
||||
|
||||
if (response.status === 400) {
|
||||
|
||||
var view = this;
|
||||
var validationErrors = JSON.parse(response.responseText);
|
||||
_.each(validationErrors, function (error) {
|
||||
view.$el.processServerError(error);
|
||||
});
|
||||
}
|
||||
this.model.trigger('validation:failed', response);
|
||||
};
|
||||
|
||||
var validatedSync = function (method, model,options) {
|
||||
this.$el.removeAllErrors();
|
||||
var validatedSync = function (method, model, options) {
|
||||
model.trigger('validation:sync');
|
||||
// this.$el.removeAllErrors();
|
||||
arguments[2].isValidatedCall = true;
|
||||
return model._originalSync.apply(this, arguments).fail(errorHandler.bind(this));
|
||||
};
|
||||
|
@ -39,6 +32,21 @@ define(
|
|||
|
||||
this.prototype.onRender = function () {
|
||||
|
||||
this.listenTo(this.model, 'validation:sync', function () {
|
||||
this.$el.removeAllErrors();
|
||||
});
|
||||
|
||||
this.listenTo(this.model, 'validation:failed', function (response) {
|
||||
if (response.status === 400) {
|
||||
|
||||
var view = this;
|
||||
var validationErrors = JSON.parse(response.responseText);
|
||||
_.each(validationErrors, function (error) {
|
||||
view.$el.processServerError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Validation.bind(this);
|
||||
this.bindToModelValidation = bindToModel.bind(this);
|
||||
|
||||
|
@ -55,6 +63,10 @@ define(
|
|||
|
||||
if (this.model) {
|
||||
Validation.unbind(this);
|
||||
|
||||
//If we don't do this the next time the model is used the sync is bound to an old view
|
||||
this.model.sync = this.model._originalSync;
|
||||
this.model._originalSync = undefined;
|
||||
}
|
||||
|
||||
if (originalBeforeClose) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue