From 016ed4a49dab418eea4e6fd46355738caf7da095 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 29 Aug 2018 15:24:50 +1000 Subject: [PATCH] fixing some validation issues --- .../components/content/edit.controller.js | 28 +++++++++++++++++-- .../services/contenteditinghelper.service.js | 4 +-- .../src/views/components/content/edit.html | 6 +++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index 171fec88e5..fdccf8080a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -132,17 +132,39 @@ initVariant(activeVariant); + var variantCulture = activeVariant.language ? activeVariant.language.culture : "invariant"; + //If there are no editors yet then create one with the current content. //if there's already a main editor then update it with the current content. if ($scope.editors.length === 0) { var editor = { - content: activeVariant + content: activeVariant, + //used for "track-by" ng-repeat + culture: variantCulture }; $scope.editors.push(editor); } else { - //this will mean there is only one - $scope.editors[0].content = activeVariant; + + //check if the current editor is the same culture + var currentIndex = _.findIndex($scope.editors, function (e) { + return e.culture === variantCulture; + }); + + if (currentIndex < 0) { + //not the current culture which means we need to modify the array, + //if we just replace the content object at the zero index, the rg-repeat will not update + //which means directives do not refresh which cause problems + $scope.editors.splice(0, 1, { + content: activeVariant, + //used for "track-by" ng-repeat + culture: variantCulture + }); + } + else { + //replace the content for the same culture + $scope.editors[0].content = activeVariant; + } if ($scope.editors.length > 1) { //now re-sync any other editor content (i.e. if split view is open) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js index 7b80694e3b..9fe3324a8f 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js @@ -599,8 +599,8 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica //add model state errors to notifications if (args.showNotifications) { - for (var e in modelState) { - notificationsService.error("Validation", modelState[e][0]); + for (var e in args.err.data.ModelState) { + notificationsService.error("Validation", args.err.data.ModelState[e][0]); } } diff --git a/src/Umbraco.Web.UI.Client/src/views/components/content/edit.html b/src/Umbraco.Web.UI.Client/src/views/components/content/edit.html index 41ddd04584..fb131d9055 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/content/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/content/edit.html @@ -7,7 +7,10 @@
-
+
+ +