Gets the tree to display the culture specific name
This commit is contained in:
@@ -899,7 +899,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
{
|
||||
variantInfo[info.LanguageId] = info.Name;
|
||||
}
|
||||
entity.AdditionalData["VariantInfo"] = variantInfo;
|
||||
entity.AdditionalData["CultureNames"] = variantInfo;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ namespace Umbraco.Tests.Services
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
Assert.AreEqual(1, entities[i].AdditionalData.Count);
|
||||
Assert.AreEqual("VariantInfo", entities[i].AdditionalData.Keys.First());
|
||||
Assert.AreEqual("CultureNames", entities[i].AdditionalData.Keys.First());
|
||||
var variantInfo = entities[i].AdditionalData.First().Value as IDictionary<int, string>;
|
||||
Assert.IsNotNull(variantInfo);
|
||||
var keys = variantInfo.Keys.ToList();
|
||||
|
||||
@@ -209,22 +209,24 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
result = Services.EntityService.GetChildren(entityId, UmbracoObjectType).ToArray();
|
||||
}
|
||||
|
||||
if (langId.HasValue)
|
||||
|
||||
//This should really never be null, but we'll error check anyways
|
||||
int? currLangId = langId.HasValue ? langId.Value : Services.LocalizationService.GetDefaultVariantLanguage()?.Id;
|
||||
|
||||
//Try to see if there is a variant name for the current language for the item and set the name accordingly.
|
||||
//If any of this fails, the tree node name will remain the default invariant culture name.
|
||||
//fixme - what if there is no name found at all ? This could occur if the doc type is variant and the user fills in all language values, then creates a new lang, sets it as default and deletes all other pre-existing langs
|
||||
if (currLangId.HasValue)
|
||||
{
|
||||
//need to update all node names
|
||||
//TODO: This is not currently stored, we need to wait until U4-11128 is complete for this to work, in the meantime
|
||||
// we'll mock using this and it will just be some mock data
|
||||
foreach(var e in result)
|
||||
foreach (var e in result)
|
||||
{
|
||||
if (e.AdditionalData.TryGetValue("VariantInfo", out var variantNames))
|
||||
{
|
||||
var casted = (IDictionary<int, string>)variantNames;
|
||||
e.Name = casted[langId.Value];
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Name = e.Name + " (lang: " + langId.Value + ")";
|
||||
if (e.AdditionalData.TryGetValue("CultureNames", out var cultureNames)
|
||||
&& cultureNames is IDictionary<int, string> cnd)
|
||||
{
|
||||
if (cnd.TryGetValue(currLangId.Value, out var name))
|
||||
{
|
||||
e.Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user