Child nodes of a list view should now render when set as a start node

This commit is contained in:
Robert
2018-05-15 11:21:37 +02:00
parent 324cd7e98f
commit 5cd80daa3f
2 changed files with 39 additions and 5 deletions

View File

@@ -203,7 +203,9 @@ namespace Umbraco.Web.Trees
entityId = entity.Id;
}
return Services.EntityService.GetChildren(entityId, UmbracoObjectType).ToArray();
var v2 = Services.EntityService.GetChildren(entityId, UmbracoObjectType).ToList();
return v2;
}
/// <summary>
@@ -274,6 +276,37 @@ namespace Umbraco.Web.Trees
return GetTreeNodesInternal(id, queryStrings);
}
/// <summary>
/// Check to see if we should return children of a container node
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
/// <remarks>
/// This is required in case a user has custom start nodes that are children of a list view since in that case we'll need to render the tree node. In normal cases we don't render
/// children of a list view.
/// </remarks>
protected bool ShouldRenderChildrenOfContainer(IUmbracoEntity e)
{
var isContainer = e.IsContainer();
var renderChildren = e.HasChildren() && (isContainer == false);
//Here we need to figure out if the node is a container and if so check if the user has a custom start node, then check if that start node is a child
// of this container node. If that is true, the HasChildren must be true so that the tree node still renders even though this current node is a container/list view.
if (isContainer && UserStartNodes.Length > 0 && UserStartNodes.Contains(Constants.System.Root) == false)
{
var startNodes = Services.EntityService.GetAll(UmbracoObjectType, UserStartNodes);
//if any of these start nodes' parent is current, then we need to render children normally so we need to switch some logic and tell
// the UI that this node does have children and that it isn't a container
if (startNodes.Any(x => x.ParentId == e.Id))
{
renderChildren = true;
}
}
return renderChildren;
}
/// <summary>
/// Before we make a call to get the tree nodes we have to check if they can actually be rendered
/// </summary>
@@ -290,7 +323,7 @@ namespace Umbraco.Web.Trees
//before we get the children we need to see if this is a container node
//test if the parent is a listview / container
if (current != null && current.IsContainer())
if (current != null && ShouldRenderChildrenOfContainer(current) == false)
{
//no children!
return new TreeNodeCollection();