diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umbtree.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbtree.directive.js index 091b18da83..346592dfdf 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/umbtree.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbtree.directive.js @@ -132,8 +132,26 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat //reset current node selection //scope.currentNode = null; - //filter the path for root node ids + //Filter the path for root node ids (we don't want to pass in -1 or 'init') + args.path = _.filter(args.path, function (item) { return (item !== "init" && item !== "-1"); }); + + //Once those are filtered we need to check if the current user has a special start node id, + // if they do, then we're going to trim the start of the array for anything found from that start node + // and previous so that the tree syncs properly. The tree syncs from the top down and if there are parts + // of the tree's path in there that don't actually exist in the dom/model then syncing will not work. + + var startNodes = [Umbraco.Sys.ServerVariables.security.startContentId, Umbraco.Sys.ServerVariables.security.startMediaId]; + _.each(startNodes, function (i) { + var found = _.find(args.path, function(p) { + return String(p) === String(i); + }); + if (found) { + args.path = args.path.splice(_.indexOf(args.path, found)); + } + }); + + loadPath(args.path, args.forceReload, args.activate); return deferred.promise; diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js b/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js index 8049b452d3..d52ef28814 100644 --- a/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js +++ b/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js @@ -33,6 +33,10 @@ Umbraco.Sys.ServerVariables = { { alias: "myTree", packageFolder: "MyPackage" } ] }, + security : { + startContentId: -1, + startMediaId: -1 + }, isDebuggingEnabled: true, application: { assemblyVersion: "1", diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index 9778e9daf9..f0236083ae 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -235,6 +235,13 @@ namespace Umbraco.Web.Editors {"trees", GetTreePluginsMetaData()} } }, + { + "security", new Dictionary + { + {"startContentId", Security.CurrentUser.StartContentId}, + {"startMediaId", Security.CurrentUser.StartMediaId} + } + }, {"isDebuggingEnabled", HttpContext.IsDebuggingEnabled}, { "application", GetApplicationState()