#3419 added extra parameter to createSingleRoot node method so it will always show a single tree. If a single tree doesn't have children it does not show

This commit is contained in:
Dave Woestenborghs
2018-10-25 08:54:17 +02:00
parent d5cc658811
commit 25a90ffbf5
2 changed files with 12 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ namespace Umbraco.Web.Models.Trees
{
private static readonly string RootId = Core.Constants.System.Root.ToString(CultureInfo.InvariantCulture);
private bool _isGroup;
private bool _alwaysShow;
/// <summary>
/// Creates a group node for grouped multiple trees
@@ -87,13 +88,15 @@ namespace Umbraco.Web.Models.Trees
/// <param name="menuUrl"></param>
/// <param name="title"></param>
/// <param name="children"></param>
/// <param name="alwaysShowRootNode"></param>
/// <returns></returns>
public static TreeRootNode CreateSingleTreeRoot(string nodeId, string getChildNodesUrl, string menuUrl, string title, TreeNodeCollection children)
public static TreeRootNode CreateSingleTreeRoot(string nodeId, string getChildNodesUrl, string menuUrl, string title, TreeNodeCollection children, bool alwaysShowRootNode = false)
{
return new TreeRootNode(nodeId, getChildNodesUrl, menuUrl)
{
Children = children,
Name = title
Name = title,
_alwaysShow = alwaysShowRootNode
};
}
@@ -150,6 +153,6 @@ namespace Umbraco.Web.Models.Trees
/// This is used in the UI to configure a full screen section/app
/// </remarks>
[DataMember(Name = "containsTrees")]
public bool ContainsTrees => Children.Count > 0;
public bool ContainsTrees => Children.Count > 0 || _alwaysShow;
}
}

View File

@@ -171,12 +171,17 @@ namespace Umbraco.Web.Trees
throw new InvalidOperationException("Could not create root node for tree " + configTree.Alias);
}
var treeAttribute = configTree.GetTreeAttribute();
var sectionRoot = TreeRootNode.CreateSingleTreeRoot(
rootId,
rootNode.Result.ChildNodesUrl,
rootNode.Result.MenuUrl,
rootNode.Result.Name,
byControllerAttempt.Result);
byControllerAttempt.Result,
treeAttribute.AlwaysShowRootItem);
//assign the route path based on the root node, this means it will route there when the section is navigated to
//and no dashboards will be available for this section