Gets tree syncing working, updates the GetApplicationTrees to still return a single Root since we require this everywhere for JS, fixes full screen section and makes users a full screen section (and reduces unecessary code), removes code to avoid breaking changes from v7
This commit is contained in:
@@ -7,6 +7,7 @@ using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Trees;
|
||||
using Section = Umbraco.Web.Models.ContentEditing.Section;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
@@ -30,6 +31,7 @@ namespace Umbraco.Web.Editors
|
||||
// this is a bit nasty since we'll be proxying via the app tree controller but we sort of have to do that
|
||||
// since tree's by nature are controllers and require request contextual data - and then we have to
|
||||
// remember to inject properties - nasty indeed
|
||||
// fixme - this controller could/should be able to be created from the container and/or from webapi's IHttpControllerTypeResolver
|
||||
var appTreeController = new ApplicationTreeController();
|
||||
Current.Container.InjectProperties(appTreeController);
|
||||
appTreeController.ControllerContext = ControllerContext;
|
||||
@@ -49,20 +51,35 @@ namespace Umbraco.Web.Editors
|
||||
if (hasDashboards == false)
|
||||
{
|
||||
//get the first tree in the section and get it's root node route path
|
||||
var sectionTrees = appTreeController.GetApplicationTrees(section.Alias, null, null).Result;
|
||||
|
||||
//Root node trees are now in collection
|
||||
var firstTree = sectionTrees.FirstOrDefault();
|
||||
|
||||
section.RoutePath = firstTree.IsContainer == false || firstTree.Children.Count == 0
|
||||
? firstTree.RoutePath
|
||||
: firstTree.Children[0].RoutePath;
|
||||
var sectionRoot = appTreeController.GetApplicationTrees(section.Alias, null, null).Result;
|
||||
section.RoutePath = GetRoutePathForFirstTree(sectionRoot);
|
||||
}
|
||||
}
|
||||
|
||||
return sectionModels;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the first non root/group node's route path
|
||||
/// </summary>
|
||||
/// <param name="rootNode"></param>
|
||||
/// <returns></returns>
|
||||
private string GetRoutePathForFirstTree(TreeRootNode rootNode)
|
||||
{
|
||||
if (!rootNode.IsContainer || !rootNode.ContainsTrees)
|
||||
return rootNode.RoutePath;
|
||||
|
||||
foreach(var node in rootNode.Children)
|
||||
{
|
||||
if (node is TreeRootNode groupRoot)
|
||||
return GetRoutePathForFirstTree(groupRoot);//recurse to get the first tree in the group
|
||||
else
|
||||
return node.RoutePath;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all the sections that the user has access to
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user