mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-18 21:55:12 -04:00
Fixed: Error messages not being shown in the UI or being shown in the wrong place
This commit is contained in:
@@ -30,7 +30,7 @@ define(
|
||||
}
|
||||
};
|
||||
|
||||
this.prototype.beforeClose = function () {
|
||||
this.prototype.onBeforeClose = function () {
|
||||
|
||||
if (this._modelBinder) {
|
||||
this._modelBinder.unbind();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user