Make sure treepicker URLs are displayed for the current editor culture

This commit is contained in:
Kenn Jacobsen
2019-08-12 21:52:00 +02:00
committed by Sebastiaan Janssen
parent 5452ebaf6d
commit 438133ae1f
2 changed files with 12 additions and 4 deletions

View File

@@ -104,21 +104,26 @@ function entityResource($q, $http, umbRequestHelper) {
*
* @param {Int} id Id of node to return the public url to
* @param {string} type Object type name
* @param {string} culture Culture
* @returns {Promise} resourcePromise object containing the url.
*
*/
getUrl: function (id, type) {
getUrl: function (id, type, culture) {
if (id === -1 || id === "-1") {
return "";
}
if (!culture) {
culture = "";
}
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"entityApiBaseUrl",
"GetUrl",
[{ id: id }, {type: type }])),
[{ id: id }, {type: type }, {culture: culture }])),
'Failed to retrieve url for id:' + id);
},

View File

@@ -211,17 +211,20 @@ namespace Umbraco.Web.Editors
/// </summary>
/// <param name="id">Int id of the entity to fetch URL for</param>
/// <param name="type">The type of entity such as Document, Media, Member</param>
/// <param name="culture">The culture to fetch the URL for</param>
/// <returns>The URL or path to the item</returns>
/// <remarks>
/// We are not restricting this with security because there is no sensitive data
/// </remarks>
public HttpResponseMessage GetUrl(int id, UmbracoEntityTypes type)
public HttpResponseMessage GetUrl(int id, UmbracoEntityTypes type, string culture = null)
{
culture = culture ?? ClientCulture();
var returnUrl = string.Empty;
if (type == UmbracoEntityTypes.Document)
{
var foundUrl = UmbracoContext.Url(id);
var foundUrl = UmbracoContext.Url(id, culture);
if (string.IsNullOrEmpty(foundUrl) == false && foundUrl != "#")
{
returnUrl = foundUrl;