diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js
index 21a8188f8d..bcb744f52d 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js
@@ -52,14 +52,6 @@ function sectionsDirective($timeout, $window, navigationService, treeService, se
}
});
- //When the user logs in
- scope.$on("authenticated", function (evt, data) {
- //populate their sections if the user has changed
- if (data.lastUserId !== data.user.id) {
- loadSections();
- }
- });
-
//on page resize
window.onresize = calculateHeight;
@@ -83,6 +75,8 @@ function sectionsDirective($timeout, $window, navigationService, treeService, se
scope.trayClick = function(){
navigationService.showTray();
};
+
+ loadSections();
}
};
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 e8f5d8b2bd..27acd7650a 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
@@ -35,7 +35,7 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
'';
}
template += '
' +
'' +
'';
@@ -217,7 +217,6 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
//anytime we want to load the tree we need to disable the delete animations
deleteAnimations = false;
- //use $q.when because a promise OR raw data might be returned.
treeService.getTree({ section: scope.section, tree: scope.treealias, cacheKey: scope.cachekey, isDialog: scope.isdialog ? scope.isdialog : false })
.then(function(data) {
//set the data once we have it
@@ -327,10 +326,8 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
scope.altSelect = function(e, n, ev) {
emitEvent("treeNodeAltSelect", { element: e, tree: scope.tree, node: n, event: ev });
};
-
-
+
//watch for section changes
- //TODO: Surely this shouldn't be here!??
scope.$watch("section", function(newVal, oldVal) {
if (!scope.tree) {
@@ -352,19 +349,9 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
activeTree = undefined;
}
});
-
- //When the user logs in
- scope.$on("authenticated", function(evt, data) {
- //populate the tree if the user has changed
- if (data.lastUserId !== data.user.id) {
- treeService.clearCache();
- scope.tree = null;
-
- setupExternalEvents();
- loadTree();
- }
- });
-
+
+ setupExternalEvents();
+ loadTree();
};
}
};
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js
index d5e59cfd35..0c15e448ac 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js
@@ -151,20 +151,9 @@ angular.module("umbraco.directives")
scope.setTreePadding = function(node) {
return { 'padding-left': (node.level * 20) + "px" };
};
-
- scope.expandActivePath = function(node, activeTree, activePath) {
- if(activePath || activeTree){
- if(node.metaData.treeAlias && activeTree === node.metaData.treeAlias){
- scope.loadChildren(null, scope.node, true);
- }else if( !node.metaData.treeAlias && activePath.indexOf(node.id) >= 0){
- scope.loadChildren(null, scope.node, true);
- }
- }
- };
//if the current path contains the node id, we will auto-expand the tree item children
- scope.expandActivePath(scope.node, scope.activetree, scope.path);
scope.node.stateCssClass = (scope.node.cssClasses || []).join(" ");
if(scope.node.style){
diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js
index e1230dfae8..9510a00185 100644
--- a/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js
+++ b/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js
@@ -62,7 +62,7 @@ function entityResource($q, $http, umbRequestHelper) {
umbRequestHelper.getApiUrl(
"entityApiBaseUrl",
"GetPath",
- [{ id: id, type: type }])),
+ [{ id: id }, {type: type }])),
'Failed to retrieve path for id:' + id);
},
diff --git a/src/Umbraco.Web.UI.Client/src/common/services/tree.service.js b/src/Umbraco.Web.UI.Client/src/common/services/tree.service.js
index 6c03c4ed11..c4bbd1e40a 100644
--- a/src/Umbraco.Web.UI.Client/src/common/services/tree.service.js
+++ b/src/Umbraco.Web.UI.Client/src/common/services/tree.service.js
@@ -497,81 +497,80 @@ function treeService($q, treeResource, iconHelper, notificationsService, $rootSc
var currPathIndex = 0;
//if the first id is the root node and there's only one... then consider it synced
if (String(args.path[currPathIndex]) === String(args.node.id)) {
-
if (args.path.length === 1) {
//return the root
deferred.resolve(root);
+ return deferred.promise;
}
else {
+ //move to the next path part and continue
currPathIndex = 1;
}
}
- else {
-
- //now that we have the first id to lookup, we can start the process
+
+ //now that we have the first id to lookup, we can start the process
- var self = this;
- var node = args.node;
-
- var doSync = function() {
- //check if it exists in the already loaded children
- var child = self.getChildNode(node, args.path[currPathIndex]);
- if (child) {
- if (args.path.length === (currPathIndex + 1)) {
- //woot! synced the node
- if (!args.forceReload) {
- deferred.resolve(child);
- }
- else {
- //even though we've found the node if forceReload is specified
- //we want to go update this single node from the server
- self.reloadNode(child).then(function(reloaded) {
- deferred.resolve(reloaded);
- }, function() {
- deferred.reject();
- });
- }
+ var self = this;
+ var node = args.node;
+
+ var doSync = function () {
+ //check if it exists in the already loaded children
+ var child = self.getChildNode(node, args.path[currPathIndex]);
+ if (child) {
+ if (args.path.length === (currPathIndex + 1)) {
+ //woot! synced the node
+ if (!args.forceReload) {
+ deferred.resolve(child);
}
else {
- //now we need to recurse with the updated node/currPathIndex
- currPathIndex++;
- node = child;
- //recurse
- doSync();
+ //even though we've found the node if forceReload is specified
+ //we want to go update this single node from the server
+ self.reloadNode(child).then(function (reloaded) {
+ deferred.resolve(reloaded);
+ }, function () {
+ deferred.reject();
+ });
}
}
else {
- //the current node doesn't have it's children loaded, so go get them
- self.loadNodeChildren({ node: node, section: node.section }).then(function () {
- //ok, got the children, let's find it
- var found = self.getChildNode(node, args.path[currPathIndex]);
- if (found) {
- if (args.path.length === (currPathIndex + 1)) {
- //woot! synced the node
- deferred.resolve(found);
- }
- else {
- //now we need to recurse with the updated node/currPathIndex
- currPathIndex++;
- node = found;
- //recurse
- doSync();
- }
+ //now we need to recurse with the updated node/currPathIndex
+ currPathIndex++;
+ node = child;
+ //recurse
+ doSync();
+ }
+ }
+ else {
+ //the current node doesn't have it's children loaded, so go get them
+ self.loadNodeChildren({ node: node, section: node.section }).then(function () {
+ //ok, got the children, let's find it
+ var found = self.getChildNode(node, args.path[currPathIndex]);
+ if (found) {
+ if (args.path.length === (currPathIndex + 1)) {
+ //woot! synced the node
+ deferred.resolve(found);
}
else {
- //fail!
- deferred.reject();
+ //now we need to recurse with the updated node/currPathIndex
+ currPathIndex++;
+ node = found;
+ //recurse
+ doSync();
}
- }, function () {
+ }
+ else {
//fail!
deferred.reject();
- });
- }
- };
+ }
+ }, function () {
+ //fail!
+ deferred.reject();
+ });
+ }
+ };
- //start
- doSync();
- }
+ //start
+ doSync();
return deferred.promise;
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js
index 52195bc253..a40fb110fb 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js
@@ -15,6 +15,8 @@ angular.module("umbraco").controller("Umbraco.Dialogs.LinkPickerController",
if(!$scope.target.path) {
entityResource.getPath($scope.target.id, "Document").then(function (path) {
$scope.target.path = path;
+ //now sync the tree to this path
+ $scope.dialogTreeEventHandler.syncTree({ path: $scope.target.path, tree: "content" });
});
}
@@ -24,7 +26,6 @@ angular.module("umbraco").controller("Umbraco.Dialogs.LinkPickerController",
}
}
-
$scope.dialogTreeEventHandler.bind("treeNodeSelect", function(ev, args){
args.event.preventDefault();
args.event.stopPropagation();
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html
index 1c6922bbd6..b3cd07cb44 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html
+++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html
@@ -24,8 +24,7 @@
section="content"
showheader="true"
showoptions="false"
- eventhandler="dialogTreeEventHandler"
- path="target.path">
+ eventhandler="dialogTreeEventHandler">
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js
index 35a4761db5..697507df36 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js
@@ -8,7 +8,7 @@
* The main application controller
*
*/
-function MainController($scope, $rootScope, $location, $routeParams, $timeout, $http, $log, appState, notificationsService, userService, navigationService, historyService, legacyJsLoader, updateChecker) {
+function MainController($scope, $rootScope, $location, $routeParams, $timeout, $http, $log, appState, treeService, notificationsService, userService, navigationService, historyService, legacyJsLoader, updateChecker) {
var legacyTreeJsLoaded = false;
@@ -89,9 +89,10 @@ function MainController($scope, $rootScope, $location, $routeParams, $timeout, $
//if the user has changed we need to redirect to the root so they don't try to continue editing the
//last item in the URL
- if (data.lastUserId && data.lastUserId !== data.user.id) {
+ if (data.lastUserId !== undefined && data.lastUserId !== data.user.id) {
$location.path("/").search("");
historyService.removeAll();
+ treeService.clearCache();
}
if($scope.user.emailHash){
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js
index 0f3443b044..307dde1e3a 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js
@@ -92,6 +92,15 @@ function NavigationController($scope, $rootScope, $location, $log, $routeParams,
}
});
+ //when a user logs out or timesout
+ $scope.$on("notAuthenticated", function() {
+ $scope.authenticated = false;
+ });
+
+ //when a user is authorized setup the data
+ $scope.$on("authenticated", function(evt, data) {
+ $scope.authenticated = true;
+ });
//this reacts to the options item in the tree
//todo, migrate to nav service
@@ -108,8 +117,7 @@ function NavigationController($scope, $rootScope, $location, $log, $routeParams,
$scope.searchHide = function () {
navigationService.hideSearch();
};
-
-
+
/** Opens a dialog but passes in this scope instance to be used for the dialog */
$scope.openDialog = function (currentNode, action, currentSection) {
navigationService.showDialog({
diff --git a/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html b/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html
index dd7b4add3d..855abce027 100644
--- a/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html
+++ b/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html
@@ -1,7 +1,7 @@
-
+
@@ -61,11 +61,10 @@
-