Cleans up some more tree code that is not used or required, moves the ui.treeEventHandler to a local var in the nav service since it doesn't need to be exposed, fixes main controller redirecting due to an undefined check.

This commit is contained in:
Shannon
2013-11-13 20:14:33 +11:00
parent b9d22b2577
commit 01589f0a35
4 changed files with 22 additions and 26 deletions

View File

@@ -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" 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" node="child" current-node="currentNode" tree="child" section="{{section}}" ng-animate="animation()"></umb-tree-item>' +
'</ul>' +
'</li>' +
'</ul>';
@@ -51,10 +51,7 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
// reload it. This saves a lot on processing if someone is navigating in and out of the same section many times
// since it saves on data retreival and DOM processing.
var lastSection = "";
//keeps track of the currently active tree being called by editors syncing
var activeTree;
//setup a default internal handler
if (!scope.eventhandler) {
scope.eventhandler = $({});
@@ -346,7 +343,6 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
//store the new section to be loaded as the last section
//clear any active trees to reset lookups
lastSection = newVal;
activeTree = undefined;
}
});

View File

@@ -160,7 +160,7 @@ angular.module("umbraco.directives")
$(element).find("i").attr("style", scope.node.style);
}
var template = '<ul ng-class="{collapsed: !node.expanded}"><umb-tree-item ng-repeat="child in node.children" eventhandler="eventhandler" activetree="{{activetree}}" tree="tree" current-node="currentNode" node="child" section="{{section}}" ng-animate="animation()"></umb-tree-item></ul>';
var template = '<ul ng-class="{collapsed: !node.expanded}"><umb-tree-item ng-repeat="child in node.children" eventhandler="eventhandler" tree="tree" current-node="currentNode" node="child" section="{{section}}" ng-animate="animation()"></umb-tree-item></ul>';
var newElement = angular.element(template);
$compile(newElement)(scope);
element.append(newElement);

View File

@@ -22,13 +22,13 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
var currentDialog = null;
//tracks the screen size as a tablet
var isTablet = false;
//the main tree event handler, which gets assigned via the setupTreeEvents method
var mainTreeEventHandler = null;
//TODO: Once most of the state vars have been refactored out to use appState, this UI object will be internal ONLY and will not be
// exposed from this service.
var ui = {
currentPath: undefined,
currentTree: undefined,
treeEventHandler: undefined,
currentNode: undefined,
//a string/name reference for the currently set ui mode
@@ -197,10 +197,10 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
// node on the ui object?? This is a mess.
setupTreeEvents: function(treeEventHandler, scope) {
this.ui.treeEventHandler = treeEventHandler;
mainTreeEventHandler = treeEventHandler;
//when a tree node is synced this event will fire, this allows us to set the currentNode
this.ui.treeEventHandler.bind("treeSynced", function (ev, args) {
mainTreeEventHandler.bind("treeSynced", function (ev, args) {
//set the global current node
ui.currentNode = args.node;
@@ -214,7 +214,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
});
//this reacts to the options item in the tree
this.ui.treeEventHandler.bind("treeOptionsClick", function(ev, args) {
mainTreeEventHandler.bind("treeOptionsClick", function(ev, args) {
ev.stopPropagation();
ev.preventDefault();
@@ -231,7 +231,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
service.showMenu(ev, args);
});
this.ui.treeEventHandler.bind("treeNodeAltSelect", function(ev, args) {
mainTreeEventHandler.bind("treeNodeAltSelect", function(ev, args) {
ev.stopPropagation();
ev.preventDefault();
@@ -244,7 +244,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
//this reacts to tree items themselves being clicked
//the tree directive should not contain any handling, simply just bubble events
this.ui.treeEventHandler.bind("treeNodeSelect", function(ev, args) {
mainTreeEventHandler.bind("treeNodeSelect", function(ev, args) {
var n = args.node;
ev.stopPropagation();
ev.preventDefault();
@@ -314,8 +314,8 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
throw "args.tree cannot be null";
}
if (this.ui.treeEventHandler) {
this.ui.treeEventHandler.syncTree(args);
if (mainTreeEventHandler) {
mainTreeEventHandler.syncTree(args);
}
},
@@ -324,21 +324,21 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
have to set an active tree and then sync, the new API does this in one method by using syncTree
*/
_syncPath: function(path, forceReload) {
if (this.ui.treeEventHandler) {
this.ui.treeEventHandler.syncTree({ path: path, forceReload: forceReload });
if (mainTreeEventHandler) {
mainTreeEventHandler.syncTree({ path: path, forceReload: forceReload });
}
},
reloadNode: function(node) {
if (this.ui.treeEventHandler) {
this.ui.treeEventHandler.reloadNode(node);
if (mainTreeEventHandler) {
mainTreeEventHandler.reloadNode(node);
}
},
reloadSection: function(sectionAlias) {
if (this.ui.treeEventHandler) {
this.ui.treeEventHandler.clearCache({ section: sectionAlias });
this.ui.treeEventHandler.load(sectionAlias);
if (mainTreeEventHandler) {
mainTreeEventHandler.clearCache({ section: sectionAlias });
mainTreeEventHandler.load(sectionAlias);
}
},
@@ -347,8 +347,8 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
have to set an active tree and then sync, the new API does this in one method by using syncTreePath
*/
_setActiveTreeType: function (treeAlias, loadChildren) {
if (this.ui.treeEventHandler) {
this.ui.treeEventHandler._setActiveTreeType(treeAlias, loadChildren);
if (mainTreeEventHandler) {
mainTreeEventHandler._setActiveTreeType(treeAlias, loadChildren);
}
},

View File

@@ -89,7 +89,7 @@ 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 !== undefined && data.lastUserId !== data.user.id) {
if (data.lastUserId !== undefined && data.lastUserId !== null && data.lastUserId !== data.user.id) {
$location.path("/").search("");
historyService.removeAll();
treeService.clearCache();