Fixed: Error messages not being shown in the UI or being shown in the wrong place

This commit is contained in:
Mark McDowall 2014-06-04 08:38:26 -07:00
parent 9916479f02
commit 545bc756f2
13 changed files with 66 additions and 34 deletions

View File

@ -19,6 +19,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("The Office - S01E01 - Pilot [HTDV-1080p]", "DRONE")]
[TestCase("The.Walking.Dead.S04E13.720p.WEB-DL.AAC2.0.H.264-Cyphanix", "Cyphanix")]
[TestCase("Arrow.S02E01.720p.WEB-DL.DD5.1.H.264.mkv", "DRONE")]
[TestCase("Series Title S01E01 Episode Title", "DRONE")]
public void should_parse_release_group(string title, string expected)
{
Parser.Parser.ParseReleaseGroup(title).Should().Be(expected);

View File

@ -30,7 +30,7 @@ define(
}
};
this.prototype.beforeClose = function () {
this.prototype.onBeforeClose = function () {
if (this._modelBinder) {
this._modelBinder.unbind();

View File

@ -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) {

View File

@ -1,5 +1,6 @@
<div id="x-download-clients-region"></div>
<div class="form-horizontal">
<div id="x-download-handling-region"></div>
<div id="x-dronefactory-region"></div>
</div>

View File

@ -26,7 +26,7 @@ define([
this.model.set({
id : undefined,
name : this.model.get('implementation'),
name : undefined,
enable : true
});

View File

@ -22,13 +22,18 @@ define([
'click .x-save-and-add': '_saveAndAdd',
'click .x-delete' : '_delete',
'click .x-back' : '_back',
'click .x-test' : '_test'
'click .x-close' : '_close',
'click .x-test' : '_test'
},
initialize: function (options) {
this.targetCollection = options.targetCollection;
},
onBeforeClose: function () {
window.alert('closing down!');
},
_save: function () {
var self = this;
var promise = this.model.save();
@ -67,6 +72,19 @@ define([
require('Settings/Indexers/Add/IndexerSchemaModal').open(this.targetCollection);
},
_close: function () {
if (this.model.isNew()) {
this.model.destroy();
}
else {
this.model.fetch();
}
vent.trigger(vent.Commands.CloseModalCommand);
},
_test: function () {
var testCommand = 'test{0}'.format(this.model.get('implementation'));
var properties = {};

View File

@ -1,7 +1,7 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<button type="button" class="close x-close" aria-hidden="true">&times;</button>
{{#if id}}
<h3>Edit - {{implementation}}</h3>
{{else}}
@ -48,7 +48,7 @@
<!-- Testing is currently not yet supported for indexers, but leaving the infrastructure for later -->
<!-- <button class="btn x-test">test <i class="x-test-icon icon-nd-test"/></button> -->
<button class="btn" data-dismiss="modal">cancel</button>
<button class="btn x-close">cancel</button>
<div class="btn-group">
<button class="btn btn-primary x-save">save</button>

View File

@ -2,5 +2,5 @@
<div id="episode-naming"></div>
<div id="sorting"></div>
<div id="file-management"></div>
<div id="permissions"></div>
{{#if_mono}}<div id="permissions"></div>{{/if_mono}}
</div>

View File

@ -1,5 +1,4 @@
{{#if_mono}}
<fieldset class="advanced-setting">
<fieldset class="advanced-setting">
<legend>Permissions</legend>
<div class="form-group">
@ -73,4 +72,3 @@
</div>
</div>
</fieldset>
{{/if_mono}}

View File

@ -9,15 +9,15 @@ define(
return Marionette.AppRouter.extend({
initialize: function () {
vent.on(vent.Commands.OpenControlPanelCommand, this._openControlPanel, this);
vent.on(vent.Commands.CloseControlPanelCommand, this._closeControlPanel, this);
vent.on(vent.Commands.OpenControlPanelCommand, this._openModal, this);
vent.on(vent.Commands.CloseControlPanelCommand, this._closeModal, this);
},
_openControlPanel: function (view) {
_openModal: function (view) {
AppLayout.controlPanelRegion.show(view);
},
_closeControlPanel: function () {
_closeModal: function () {
AppLayout.controlPanelRegion.closePanel();
}
});

View File

@ -15,8 +15,8 @@ define(
return Marionette.AppRouter.extend({
initialize: function () {
vent.on(vent.Commands.OpenModalCommand, this._openControlPanel, this);
vent.on(vent.Commands.CloseModalCommand, this._closeControlPanel, this);
vent.on(vent.Commands.OpenModalCommand, this._openModal, this);
vent.on(vent.Commands.CloseModalCommand, this._closeModal, this);
vent.on(vent.Commands.EditSeriesCommand, this._editSeries, this);
vent.on(vent.Commands.DeleteSeriesCommand, this._deleteSeries, this);
vent.on(vent.Commands.ShowEpisodeDetails, this._showEpisode, this);
@ -25,12 +25,12 @@ define(
vent.on(vent.Commands.ShowRenamePreview, this._showRenamePreview, this);
},
_openControlPanel: function (view) {
_openModal: function (view) {
AppLayout.modalRegion.show(view);
},
_closeControlPanel: function () {
AppLayout.modalRegion.closePanel();
_closeModal: function () {
AppLayout.modalRegion.closeModal();
},
_editSeries: function (options) {

View File

@ -11,7 +11,7 @@ define(
constructor: function () {
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
this.on('show', this.showPanel, this);
this.on('show', this.showModal, this);
},
getEl: function (selector) {
@ -20,7 +20,7 @@ define(
return $el;
},
showPanel: function () {
showModal: function () {
this.$el.addClass('modal fade');
//need tab index so close on escape works
@ -32,7 +32,7 @@ define(
'backdrop': 'static'});
},
closePanel: function () {
closeModal: function () {
$(this.el).modal('hide');
this.reset();
}

View File

@ -16,7 +16,6 @@ define(
return this.name.toLowerCase() === validationName;
});
if (input.length === 0) {
input = this.find('[validation-name]').filter(function () {
return $(this).attr('validation-name').toLowerCase() === validationName;
@ -58,7 +57,10 @@ define(
};
$.fn.addFormError = function (error) {
this.find('.form-group').parent().prepend('<div class="alert alert-error validation-error">' + error.errorMessage + '</div>');
var t1 = this.find('.form-horizontal');
var t2 = this.find('.form-horizontal').parent();
this.prepend('<div class="alert alert-danger validation-error">' + error.errorMessage + '</div>');
};
$.fn.removeAllErrors = function () {