Multi URL picker improvements for V11 (#13586)

* Use bulk lookup to find URLs for multi URL picker items

* Make sure URLs and anchors are loaded correctly when no culture is supplied
This commit is contained in:
Kenn Jacobsen
2022-12-16 13:06:27 +01:00
committed by nikolajlauridsen
parent a897e3bdd3
commit a5a80fdd41
2 changed files with 16 additions and 12 deletions

View File

@@ -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<string> anchorValues = _contentService.GetAnchorValuesFromRTEs(id, culture);

View File

@@ -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();