diff --git a/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs index 7c1504d4a..d147bc47b 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs @@ -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); diff --git a/src/UI/Mixins/AsModelBoundView.js b/src/UI/Mixins/AsModelBoundView.js index be70ec65b..0095370e0 100644 --- a/src/UI/Mixins/AsModelBoundView.js +++ b/src/UI/Mixins/AsModelBoundView.js @@ -30,7 +30,7 @@ define( } }; - this.prototype.beforeClose = function () { + this.prototype.onBeforeClose = function () { if (this._modelBinder) { this._modelBinder.unbind(); diff --git a/src/UI/Mixins/AsValidatedView.js b/src/UI/Mixins/AsValidatedView.js index 952c1da69..7a6cea293 100644 --- a/src/UI/Mixins/AsValidatedView.js +++ b/src/UI/Mixins/AsValidatedView.js @@ -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) { diff --git a/src/UI/Settings/DownloadClient/DownloadClientLayoutTemplate.html b/src/UI/Settings/DownloadClient/DownloadClientLayoutTemplate.html index 89c20761e..7450b08d3 100644 --- a/src/UI/Settings/DownloadClient/DownloadClientLayoutTemplate.html +++ b/src/UI/Settings/DownloadClient/DownloadClientLayoutTemplate.html @@ -1,5 +1,6 @@ 
+
diff --git a/src/UI/Settings/Indexers/Add/IndexerAddItemView.js b/src/UI/Settings/Indexers/Add/IndexerAddItemView.js index 859f2a008..217a1c999 100644 --- a/src/UI/Settings/Indexers/Add/IndexerAddItemView.js +++ b/src/UI/Settings/Indexers/Add/IndexerAddItemView.js @@ -26,7 +26,7 @@ define([ this.model.set({ id : undefined, - name : this.model.get('implementation'), + name : undefined, enable : true }); diff --git a/src/UI/Settings/Indexers/Edit/IndexerEditView.js b/src/UI/Settings/Indexers/Edit/IndexerEditView.js index 2f4a8b90d..004750332 100644 --- a/src/UI/Settings/Indexers/Edit/IndexerEditView.js +++ b/src/UI/Settings/Indexers/Edit/IndexerEditView.js @@ -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 = {}; diff --git a/src/UI/Settings/Indexers/Edit/IndexerEditViewTemplate.html b/src/UI/Settings/Indexers/Edit/IndexerEditViewTemplate.html index 25ea543df..75ec1d284 100644 --- a/src/UI/Settings/Indexers/Edit/IndexerEditViewTemplate.html +++ b/src/UI/Settings/Indexers/Edit/IndexerEditViewTemplate.html @@ -1,7 +1,7 @@