mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-12 16:13:58 -07:00
Fixed validation that was causing add existing series to fail
This commit is contained in:
parent
ddbcb883ca
commit
519b6debfb
6 changed files with 48 additions and 33 deletions
|
@ -12,12 +12,18 @@ define(
|
|||
var originalBeforeClose = this.prototype.onBeforeClose;
|
||||
|
||||
var errorHandler = function (response) {
|
||||
this.model.trigger('validation:failed', response);
|
||||
if (this.model) {
|
||||
this.model.trigger('validation:failed', response);
|
||||
}
|
||||
|
||||
else {
|
||||
this.trigger('validation:failed', response);
|
||||
}
|
||||
};
|
||||
|
||||
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));
|
||||
};
|
||||
|
@ -30,22 +36,34 @@ define(
|
|||
}
|
||||
};
|
||||
|
||||
var validationFailed = function (response) {
|
||||
if (response.status === 400) {
|
||||
|
||||
var view = this;
|
||||
var validationErrors = JSON.parse(response.responseText);
|
||||
_.each(validationErrors, function (error) {
|
||||
view.$el.processServerError(error);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.prototype.onRender = function () {
|
||||
|
||||
this.listenTo(this.model, 'validation:sync', function () {
|
||||
this.$el.removeAllErrors();
|
||||
});
|
||||
if (this.model) {
|
||||
this.listenTo(this.model, 'validation:sync', function () {
|
||||
this.$el.removeAllErrors();
|
||||
});
|
||||
|
||||
this.listenTo(this.model, 'validation:failed', function (response) {
|
||||
if (response.status === 400) {
|
||||
this.listenTo(this.model, 'validation:failed', validationFailed);
|
||||
}
|
||||
|
||||
var view = this;
|
||||
var validationErrors = JSON.parse(response.responseText);
|
||||
_.each(validationErrors, function (error) {
|
||||
view.$el.processServerError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
else {
|
||||
this.listenTo(this, 'validation:sync', function () {
|
||||
this.$el.removeAllErrors();
|
||||
});
|
||||
|
||||
this.listenTo(this, 'validation:failed', validationFailed);
|
||||
}
|
||||
|
||||
Validation.bind(this);
|
||||
this.bindToModelValidation = bindToModel.bind(this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue