From 086d7b6e23077bacb41d2ddce37a9ece9041ca8b Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 1 Jul 2020 13:00:56 +1000 Subject: [PATCH] ensures the udi structure works always for the validation key --- .../components/property/umbproperty.directive.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/property/umbproperty.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/property/umbproperty.directive.js index b9e607ecc9..8b3f51f0f9 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/property/umbproperty.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/property/umbproperty.directive.js @@ -5,6 +5,15 @@ **/ angular.module("umbraco.directives") .directive('umbProperty', function (userService, serverValidationManager, udiService) { + + // if only a guid is passed in, we'll ensure a correct udi structure + function ensureUdi(udi) { + if (udi && !udi.startsWith("umb://")) { + udi = udiService.build("element", udi); + } + return udi; + } + return { scope: { property: "=", @@ -29,9 +38,7 @@ angular.module("umbraco.directives") }); } - if (scope.elementUdi && !scope.elementUdi.startsWith("umb://")) { - scope.elementUdi = udiService.build("element", scope.elementUdi); - } + scope.elementUdi = ensureUdi(scope.elementUdi); }, //Define a controller for this directive to expose APIs to other directives @@ -56,6 +63,7 @@ angular.module("umbraco.directives") // the elementUdi will be empty when this is not a nested property var propAlias = $scope.propertyAlias ? $scope.propertyAlias : $scope.property.alias; + $scope.elementUdi = ensureUdi($scope.elementUdi); return serverValidationManager.createPropertyValidationKey(propAlias, $scope.elementUdi); } $scope.getValidationPath = self.getValidationPath;