diff --git a/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs b/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs index ba9809f657..42019f7c99 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs @@ -568,7 +568,7 @@ public class EntityController : UmbracoAuthorizedJsonController [HttpGet] public UrlAndAnchors GetUrlAndAnchors(int id, string? culture = "*") { - culture ??= ClientCulture(); + culture = culture is null or "*" ? ClientCulture() : culture; var url = _publishedUrlProvider.GetUrl(id, culture: culture); IEnumerable anchorValues = _contentService.GetAnchorValuesFromRTEs(id, culture); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multiurlpicker/multiurlpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multiurlpicker/multiurlpicker.controller.js index dfdc9aa779..09facf96b5 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multiurlpicker/multiurlpicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multiurlpicker/multiurlpicker.controller.js @@ -21,10 +21,6 @@ function multiUrlPickerController($scope, localizationService, entityResource, i $scope.renderModel = []; - if ($scope.preview) { - return; - } - if ($scope.model.config && parseInt($scope.model.config.maxNumber) !== 1 && $scope.umbProperty) { var propertyActions = [ removeAllEntriesAction @@ -83,7 +79,7 @@ function multiUrlPickerController($scope, localizationService, entityResource, i $scope.sortableOptions.disabled = $scope.renderModel.length === 1 || $scope.readonly; removeAllEntriesAction.isDisabled = $scope.renderModel.length === 0 || $scope.readonly; - + //Update value $scope.model.value = $scope.renderModel; } @@ -93,7 +89,7 @@ function multiUrlPickerController($scope, localizationService, entityResource, i if (!$scope.allowRemove) return; $scope.renderModel.splice($index, 1); - + setDirty(); }; @@ -208,15 +204,23 @@ function multiUrlPickerController($scope, localizationService, entityResource, i $scope.model.config.minNumber = 1; } - _.each($scope.model.value, function (item) { + const ids = []; + $scope.model.value.forEach(item => { // we must reload the "document" link URLs to match the current editor culture - if (item.udi && item.udi.indexOf("/document/") > 0) { + if (item.udi && item.udi.indexOf("/document/") > 0 && ids.indexOf(item.udi) < 0) { + ids.push(item.udi); item.url = null; - entityResource.getUrlByUdi(item.udi).then(data => { - item.url = data; - }); } }); + + if(ids.length){ + entityResource.getUrlsByIds(ids, "Document").then(function(urlMap){ + Object.keys(urlMap).forEach((udi) => { + const items = $scope.model.value.filter(item => item.udi === udi); + items.forEach(item => item.url = urlMap[udi]); + }) + }); + } } init();