V8: Support culture variant URLs in multi URL picker (#7130)
Thanks, Kenn - great work as usual 👍
This commit is contained in:
committed by
emma burstow
parent
12e88fde42
commit
bcf4c97270
@@ -127,6 +127,25 @@ function entityResource($q, $http, umbRequestHelper) {
|
||||
'Failed to retrieve url for id:' + id);
|
||||
},
|
||||
|
||||
getUrlByUdi: function (udi, culture) {
|
||||
|
||||
if (!udi) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!culture) {
|
||||
culture = "";
|
||||
}
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"entityApiBaseUrl",
|
||||
"GetUrl",
|
||||
[{ udi: udi }, {culture: culture }])),
|
||||
'Failed to retrieve url for UDI:' + udi);
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.entityResource#getById
|
||||
@@ -166,18 +185,22 @@ function entityResource($q, $http, umbRequestHelper) {
|
||||
},
|
||||
|
||||
|
||||
getUrlAndAnchors: function (id) {
|
||||
getUrlAndAnchors: function (id, culture) {
|
||||
|
||||
if (id === -1 || id === "-1") {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!culture) {
|
||||
culture = "";
|
||||
}
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"entityApiBaseUrl",
|
||||
"GetUrlAndAnchors",
|
||||
[{ id: id }])),
|
||||
[{ id: id }, {culture: culture }])),
|
||||
'Failed to retrieve url and anchors data for id ' + id);
|
||||
},
|
||||
|
||||
|
||||
@@ -144,6 +144,16 @@ function multiUrlPickerController($scope, angularHelper, localizationService, en
|
||||
if ($scope.model.validation && $scope.model.validation.mandatory && !$scope.model.config.minNumber) {
|
||||
$scope.model.config.minNumber = 1;
|
||||
}
|
||||
|
||||
_.each($scope.model.value, function (item){
|
||||
// we must reload the "document" link URLs to match the current editor culture
|
||||
if (item.udi.indexOf("/document/") > 0) {
|
||||
item.url = null;
|
||||
entityResource.getUrlByUdi(item.udi).then(function (data) {
|
||||
item.url = data;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
Reference in New Issue
Block a user