Fixes: U4-3506 Linkpicker in RTE doesn't expand tree to last selected link - missing GetPath parameter - which lead to lots of other cleanup, removes auth listening on the section and tree directives since that doesn't belong there, now the navigation controller determines what to render depending on authorization. Removes the path parameter on the umbTree and umbTreeItem since this didn't work and syncTree should be used instead. Fixed up some more tree sync logic as well.
This commit is contained in:
@@ -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();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
|
||||
'</div>';
|
||||
}
|
||||
template += '<ul>' +
|
||||
'<umb-tree-item ng-repeat="child in tree.root.children" eventhandler="eventhandler" path="{{path}}" activetree="{{activetree}}" node="child" current-node="currentNode" tree="child" section="{{section}}" ng-animate="animation()"></umb-tree-item>' +
|
||||
'<umb-tree-item ng-repeat="child in tree.root.children" eventhandler="eventhandler" activetree="{{activetree}}" node="child" current-node="currentNode" tree="child" section="{{section}}" ng-animate="animation()"></umb-tree-item>' +
|
||||
'</ul>' +
|
||||
'</li>' +
|
||||
'</ul>';
|
||||
@@ -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();
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
section="content"
|
||||
showheader="true"
|
||||
showoptions="false"
|
||||
eventhandler="dialogTreeEventHandler"
|
||||
path="target.path">
|
||||
eventhandler="dialogTreeEventHandler">
|
||||
</umb-tree>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div id="leftcolumn" ng-controller="Umbraco.NavigationController"
|
||||
ng-mouseleave="nav.leaveTree($event)" ng-mouseenter="nav.enterTree($event)">
|
||||
|
||||
<umb-sections sections="sections">
|
||||
<umb-sections sections="sections" ng-if="authenticated">
|
||||
</umb-sections>
|
||||
|
||||
<!-- navigation container -->
|
||||
@@ -61,11 +61,10 @@
|
||||
</div>
|
||||
|
||||
<!-- the tree -->
|
||||
<div id="tree" class="umb-modalcolumn-body">
|
||||
<div id="tree" class="umb-modalcolumn-body" ng-if="authenticated">
|
||||
<umb-tree
|
||||
cachekey="_"
|
||||
eventhandler="treeEventHandler"
|
||||
path="{{nav.ui.currentPath}}"
|
||||
section="{{currentSection}}"
|
||||
activetree="{{nav.ui.currentTree}}" >
|
||||
</umb-tree>
|
||||
|
||||
Reference in New Issue
Block a user