From 60c4d670da79c4f40b2b6dee453ee88e090ecca7 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 1 Nov 2013 13:54:42 +1100 Subject: [PATCH] Fixes: U4-3294 When creating new content and there are validation errors we don't redirect to edit the content, instead validation errors are displayed and we create another item --- .../common/services/servervalidationmgr.service.js | 13 ++++++++++++- .../src/views/content/content.edit.controller.js | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/servervalidationmgr.service.js b/src/Umbraco.Web.UI.Client/src/common/services/servervalidationmgr.service.js index 03f5e96ab0..fdc81a3989 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/servervalidationmgr.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/servervalidationmgr.service.js @@ -22,6 +22,10 @@ function serverValidationManager($timeout) { } function getFieldErrors(self, fieldName) { + if (!angular.isString(fieldName)) { + throw "fieldName must be a string"; + } + //find errors for this field name return _.filter(self.items, function (item) { return (item.propertyAlias === null && item.fieldName === fieldName); @@ -29,6 +33,13 @@ function serverValidationManager($timeout) { } function getPropertyErrors(self, propertyAlias, fieldName) { + if (!angular.isString(propertyAlias)) { + throw "propertyAlias must be a string"; + } + if (fieldName && !angular.isString(fieldName)) { + throw "fieldName must be a string"; + } + //find all errors for this property return _.filter(self.items, function (item) { return (item.propertyAlias === propertyAlias && (item.fieldName === fieldName || (fieldName === undefined || fieldName === ""))); @@ -68,7 +79,7 @@ function serverValidationManager($timeout) { } else { //its a property error - var propErrors = getPropertyErrors(self, { alias: callbacks[cb].propertyAlias }, callbacks[cb].fieldName); + var propErrors = getPropertyErrors(self, callbacks[cb].propertyAlias, callbacks[cb].fieldName); if (propErrors.length > 0) { executeCallback(self, propErrors, callbacks[cb].callback); } diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js index b8b628e6fc..eb9947d47d 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js @@ -120,6 +120,7 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, cont deferred.resolve(data); }, function (err) { + contentEditingHelper.handleSaveError({ redirectOnFailure: true, err: err,