Fixed validation that was causing add existing series to fail

pull/82/head
Mark McDowall 10 years ago
parent ddbcb883ca
commit 519b6debfb

@ -10,17 +10,13 @@ namespace NzbDrone.Integration.Test
[Test] [Test]
public void should_only_have_unknown_series_releases() public void should_only_have_unknown_series_releases()
{ {
var releases = Releases.All(); var releases = Releases.All();
var indexers = Indexers.All(); var indexers = Indexers.All();
releases.Should().OnlyContain(c => c.Rejections.Contains("Unknown Series")); releases.Should().OnlyContain(c => c.Rejections.Contains("Unknown Series"));
releases.Should().OnlyContain(c => BeValidRelease(c)); releases.Should().OnlyContain(c => BeValidRelease(c));
} }
private bool BeValidRelease(ReleaseResource releaseResource) private bool BeValidRelease(ReleaseResource releaseResource)
{ {
releaseResource.Age.Should().BeGreaterOrEqualTo(-1); releaseResource.Age.Should().BeGreaterOrEqualTo(-1);
@ -33,6 +29,5 @@ namespace NzbDrone.Integration.Test
return true; return true;
} }
} }
} }

@ -8,7 +8,8 @@
<div class="validation-errors"></div> <div class="validation-errors"></div>
<div class="alert alert-info">Enter the path that contains some or all of your TV series, you will be able to choose which series you want to import<button type="button" class="close" data-dismiss="alert">×</button></div> <div class="alert alert-info">Enter the path that contains some or all of your TV series, you will be able to choose which series you want to import<button type="button" class="close" data-dismiss="alert">×</button></div>
<div class="input-group x-path form-group"> <div class="form-group">
<div class="input-group x-path">
<span class="input-group-addon">&nbsp;<i class="icon-folder-open"></i></span> <span class="input-group-addon">&nbsp;<i class="icon-folder-open"></i></span>
<input class="col-md-9 form-control" type="text" validation-name="path" placeholder="Enter path to folder that contains your shows"> <input class="col-md-9 form-control" type="text" validation-name="path" placeholder="Enter path to folder that contains your shows">
<span class="input-group-btn "> <span class="input-group-btn ">
@ -17,6 +18,7 @@
</button> </button>
</span> </span>
</div> </div>
</div>
{{#if items}} {{#if items}}
<h4>Recent Folders</h4> <h4>Recent Folders</h4>

@ -130,4 +130,8 @@ li.add-new:hover {
overflow: auto; overflow: auto;
max-height: 300px; max-height: 300px;
} }
.validation-errors {
display: none;
}
} }

@ -12,12 +12,18 @@ define(
var originalBeforeClose = this.prototype.onBeforeClose; var originalBeforeClose = this.prototype.onBeforeClose;
var errorHandler = function (response) { var errorHandler = function (response) {
if (this.model) {
this.model.trigger('validation:failed', response); this.model.trigger('validation:failed', response);
}
else {
this.trigger('validation:failed', response);
}
}; };
var validatedSync = function (method, model, options) { var validatedSync = function (method, model, options) {
model.trigger('validation:sync'); model.trigger('validation:sync');
// this.$el.removeAllErrors();
arguments[2].isValidatedCall = true; arguments[2].isValidatedCall = true;
return model._originalSync.apply(this, arguments).fail(errorHandler.bind(this)); return model._originalSync.apply(this, arguments).fail(errorHandler.bind(this));
}; };
@ -30,13 +36,7 @@ define(
} }
}; };
this.prototype.onRender = function () { var validationFailed = function (response) {
this.listenTo(this.model, 'validation:sync', function () {
this.$el.removeAllErrors();
});
this.listenTo(this.model, 'validation:failed', function (response) {
if (response.status === 400) { if (response.status === 400) {
var view = this; var view = this;
@ -45,8 +45,26 @@ define(
view.$el.processServerError(error); view.$el.processServerError(error);
}); });
} }
};
this.prototype.onRender = function () {
if (this.model) {
this.listenTo(this.model, 'validation:sync', function () {
this.$el.removeAllErrors();
});
this.listenTo(this.model, 'validation:failed', validationFailed);
}
else {
this.listenTo(this, 'validation:sync', function () {
this.$el.removeAllErrors();
}); });
this.listenTo(this, 'validation:failed', validationFailed);
}
Validation.bind(this); Validation.bind(this);
this.bindToModelValidation = bindToModel.bind(this); this.bindToModelValidation = bindToModel.bind(this);

@ -30,10 +30,6 @@ define([
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
onBeforeClose: function () {
window.alert('closing down!');
},
_save: function () { _save: function () {
var self = this; var self = this;
var promise = this.model.save(); var promise = this.model.save();

@ -9,7 +9,7 @@ define(
var validationName = error.propertyName.toLowerCase(); var validationName = error.propertyName.toLowerCase();
this.find('.validation-errors') this.find('.validation-errors')
.addClass('alert alert-error') .addClass('alert alert-danger')
.append('<div><i class="icon-exclamation-sign"></i>' + error.errorMessage + '</div>'); .append('<div><i class="icon-exclamation-sign"></i>' + error.errorMessage + '</div>');
var input = this.find('[name]').filter(function () { var input = this.find('[name]').filter(function () {
@ -65,7 +65,7 @@ define(
$.fn.removeAllErrors = function () { $.fn.removeAllErrors = function () {
this.find('.error').removeClass('error'); this.find('.error').removeClass('error');
this.find('.validation-errors').removeClass('alert').removeClass('alert-error').html(''); this.find('.validation-errors').removeClass('alert').removeClass('alert-danger').html('');
this.find('.validation-error').remove(); this.find('.validation-error').remove();
return this.find('.help-inline.error-message').remove(); return this.find('.help-inline.error-message').remove();
}; };

Loading…
Cancel
Save