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
|
@ -19,6 +19,7 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||||
[TestCase("The Office - S01E01 - Pilot [HTDV-1080p]", "DRONE")]
|
[TestCase("The Office - S01E01 - Pilot [HTDV-1080p]", "DRONE")]
|
||||||
[TestCase("The.Walking.Dead.S04E13.720p.WEB-DL.AAC2.0.H.264-Cyphanix", "Cyphanix")]
|
[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("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)
|
public void should_parse_release_group(string title, string expected)
|
||||||
{
|
{
|
||||||
Parser.Parser.ParseReleaseGroup(title).Should().Be(expected);
|
Parser.Parser.ParseReleaseGroup(title).Should().Be(expected);
|
||||||
|
|
|
@ -30,7 +30,7 @@ define(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.prototype.beforeClose = function () {
|
this.prototype.onBeforeClose = function () {
|
||||||
|
|
||||||
if (this._modelBinder) {
|
if (this._modelBinder) {
|
||||||
this._modelBinder.unbind();
|
this._modelBinder.unbind();
|
||||||
|
|
|
@ -12,19 +12,12 @@ define(
|
||||||
var originalBeforeClose = this.prototype.onBeforeClose;
|
var originalBeforeClose = this.prototype.onBeforeClose;
|
||||||
|
|
||||||
var errorHandler = function (response) {
|
var errorHandler = function (response) {
|
||||||
|
this.model.trigger('validation:failed', response);
|
||||||
if (response.status === 400) {
|
|
||||||
|
|
||||||
var view = this;
|
|
||||||
var validationErrors = JSON.parse(response.responseText);
|
|
||||||
_.each(validationErrors, function (error) {
|
|
||||||
view.$el.processServerError(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var validatedSync = function (method, model,options) {
|
var validatedSync = function (method, model, options) {
|
||||||
this.$el.removeAllErrors();
|
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));
|
||||||
};
|
};
|
||||||
|
@ -39,6 +32,21 @@ define(
|
||||||
|
|
||||||
this.prototype.onRender = function () {
|
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);
|
Validation.bind(this);
|
||||||
this.bindToModelValidation = bindToModel.bind(this);
|
this.bindToModelValidation = bindToModel.bind(this);
|
||||||
|
|
||||||
|
@ -55,6 +63,10 @@ define(
|
||||||
|
|
||||||
if (this.model) {
|
if (this.model) {
|
||||||
Validation.unbind(this);
|
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) {
|
if (originalBeforeClose) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<div id="x-download-clients-region"></div>
|
<div id="x-download-clients-region"></div>
|
||||||
<div class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
|
|
||||||
<div id="x-download-handling-region"></div>
|
<div id="x-download-handling-region"></div>
|
||||||
<div id="x-dronefactory-region"></div>
|
<div id="x-dronefactory-region"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,7 +26,7 @@ define([
|
||||||
|
|
||||||
this.model.set({
|
this.model.set({
|
||||||
id : undefined,
|
id : undefined,
|
||||||
name : this.model.get('implementation'),
|
name : undefined,
|
||||||
enable : true
|
enable : true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,18 @@ define([
|
||||||
'click .x-save-and-add': '_saveAndAdd',
|
'click .x-save-and-add': '_saveAndAdd',
|
||||||
'click .x-delete' : '_delete',
|
'click .x-delete' : '_delete',
|
||||||
'click .x-back' : '_back',
|
'click .x-back' : '_back',
|
||||||
'click .x-test' : '_test'
|
'click .x-close' : '_close',
|
||||||
|
'click .x-test' : '_test'
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function (options) {
|
initialize: function (options) {
|
||||||
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();
|
||||||
|
@ -67,6 +72,19 @@ define([
|
||||||
require('Settings/Indexers/Add/IndexerSchemaModal').open(this.targetCollection);
|
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 () {
|
_test: function () {
|
||||||
var testCommand = 'test{0}'.format(this.model.get('implementation'));
|
var testCommand = 'test{0}'.format(this.model.get('implementation'));
|
||||||
var properties = {};
|
var properties = {};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<button type="button" class="close x-close" aria-hidden="true">×</button>
|
||||||
{{#if id}}
|
{{#if id}}
|
||||||
<h3>Edit - {{implementation}}</h3>
|
<h3>Edit - {{implementation}}</h3>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
<!-- Testing is currently not yet supported for indexers, but leaving the infrastructure for later -->
|
<!-- 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 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">
|
<div class="btn-group">
|
||||||
<button class="btn btn-primary x-save">save</button>
|
<button class="btn btn-primary x-save">save</button>
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
<div id="episode-naming"></div>
|
<div id="episode-naming"></div>
|
||||||
<div id="sorting"></div>
|
<div id="sorting"></div>
|
||||||
<div id="file-management"></div>
|
<div id="file-management"></div>
|
||||||
<div id="permissions"></div>
|
{{#if_mono}}<div id="permissions"></div>{{/if_mono}}
|
||||||
</div>
|
</div>
|
|
@ -1,5 +1,4 @@
|
||||||
{{#if_mono}}
|
<fieldset class="advanced-setting">
|
||||||
<fieldset class="advanced-setting">
|
|
||||||
<legend>Permissions</legend>
|
<legend>Permissions</legend>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -73,4 +72,3 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{{/if_mono}}
|
|
||||||
|
|
|
@ -9,15 +9,15 @@ define(
|
||||||
return Marionette.AppRouter.extend({
|
return Marionette.AppRouter.extend({
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
vent.on(vent.Commands.OpenControlPanelCommand, this._openControlPanel, this);
|
vent.on(vent.Commands.OpenControlPanelCommand, this._openModal, this);
|
||||||
vent.on(vent.Commands.CloseControlPanelCommand, this._closeControlPanel, this);
|
vent.on(vent.Commands.CloseControlPanelCommand, this._closeModal, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
_openControlPanel: function (view) {
|
_openModal: function (view) {
|
||||||
AppLayout.controlPanelRegion.show(view);
|
AppLayout.controlPanelRegion.show(view);
|
||||||
},
|
},
|
||||||
|
|
||||||
_closeControlPanel: function () {
|
_closeModal: function () {
|
||||||
AppLayout.controlPanelRegion.closePanel();
|
AppLayout.controlPanelRegion.closePanel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,8 +15,8 @@ define(
|
||||||
return Marionette.AppRouter.extend({
|
return Marionette.AppRouter.extend({
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
vent.on(vent.Commands.OpenModalCommand, this._openControlPanel, this);
|
vent.on(vent.Commands.OpenModalCommand, this._openModal, this);
|
||||||
vent.on(vent.Commands.CloseModalCommand, this._closeControlPanel, this);
|
vent.on(vent.Commands.CloseModalCommand, this._closeModal, this);
|
||||||
vent.on(vent.Commands.EditSeriesCommand, this._editSeries, this);
|
vent.on(vent.Commands.EditSeriesCommand, this._editSeries, this);
|
||||||
vent.on(vent.Commands.DeleteSeriesCommand, this._deleteSeries, this);
|
vent.on(vent.Commands.DeleteSeriesCommand, this._deleteSeries, this);
|
||||||
vent.on(vent.Commands.ShowEpisodeDetails, this._showEpisode, this);
|
vent.on(vent.Commands.ShowEpisodeDetails, this._showEpisode, this);
|
||||||
|
@ -25,12 +25,12 @@ define(
|
||||||
vent.on(vent.Commands.ShowRenamePreview, this._showRenamePreview, this);
|
vent.on(vent.Commands.ShowRenamePreview, this._showRenamePreview, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
_openControlPanel: function (view) {
|
_openModal: function (view) {
|
||||||
AppLayout.modalRegion.show(view);
|
AppLayout.modalRegion.show(view);
|
||||||
},
|
},
|
||||||
|
|
||||||
_closeControlPanel: function () {
|
_closeModal: function () {
|
||||||
AppLayout.modalRegion.closePanel();
|
AppLayout.modalRegion.closeModal();
|
||||||
},
|
},
|
||||||
|
|
||||||
_editSeries: function (options) {
|
_editSeries: function (options) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ define(
|
||||||
|
|
||||||
constructor: function () {
|
constructor: function () {
|
||||||
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
|
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
|
||||||
this.on('show', this.showPanel, this);
|
this.on('show', this.showModal, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
getEl: function (selector) {
|
getEl: function (selector) {
|
||||||
|
@ -20,7 +20,7 @@ define(
|
||||||
return $el;
|
return $el;
|
||||||
},
|
},
|
||||||
|
|
||||||
showPanel: function () {
|
showModal: function () {
|
||||||
this.$el.addClass('modal fade');
|
this.$el.addClass('modal fade');
|
||||||
|
|
||||||
//need tab index so close on escape works
|
//need tab index so close on escape works
|
||||||
|
@ -32,7 +32,7 @@ define(
|
||||||
'backdrop': 'static'});
|
'backdrop': 'static'});
|
||||||
},
|
},
|
||||||
|
|
||||||
closePanel: function () {
|
closeModal: function () {
|
||||||
$(this.el).modal('hide');
|
$(this.el).modal('hide');
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ define(
|
||||||
return this.name.toLowerCase() === validationName;
|
return this.name.toLowerCase() === validationName;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (input.length === 0) {
|
if (input.length === 0) {
|
||||||
input = this.find('[validation-name]').filter(function () {
|
input = this.find('[validation-name]').filter(function () {
|
||||||
return $(this).attr('validation-name').toLowerCase() === validationName;
|
return $(this).attr('validation-name').toLowerCase() === validationName;
|
||||||
|
@ -58,7 +57,10 @@ define(
|
||||||
};
|
};
|
||||||
|
|
||||||
$.fn.addFormError = function (error) {
|
$.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 () {
|
$.fn.removeAllErrors = function () {
|
||||||
|
|
Loading…
Reference in New Issue