[BUGFIX] Pagetree doesn't expands to the last saved state
authorStefan Galinski <stefan.galinski@gmail.com>
Thu, 10 May 2012 17:51:11 +0000 (19:51 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Mon, 14 May 2012 11:36:11 +0000 (13:36 +0200)
Change-Id: I0518d9dd06c7d126dfe5d885e4b2751b7e7462b6
Releases: 6.0, 4.7, 4.6, 4.5
Fixes: #36459
Reviewed-on: http://review.typo3.org/11138
Reviewed-by: Nicole Cordes
Tested-by: Nicole Cordes
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
t3lib/js/extjs/components/pagetree/javascript/Ext.ux.state.TreePanel.js

index 83bdd96..44f25db 100644 (file)
@@ -45,22 +45,23 @@ Ext.override(Ext.ux.state.TreePanel, {
                // install event handlers on TreePanel
                tree.on({
                        // add path of expanded node to stateHash
-                        beforeexpandnode:function(n) {
+                       beforeexpandnode:function(node) {
                                if (this.isRestoringState) {
                                        return;
                                }
-                               var saveID = n.id;
-                               this.stateHash[saveID.substr(1)] = 1;
+
+                               var saveID = (node.id === 'root' ? node.id : node.id.substr(1));
+                               this.stateHash[saveID] = 1;
                        },
 
                        // delete path and all subpaths of collapsed node from stateHash
-                       beforecollapsenode:function(n) {
+                       beforecollapsenode:function(node) {
                                if (this.isRestoringState) {
                                        return;
                                }
 
-                               var deleteID = n.id;
-                               delete this.stateHash[deleteID.substr(1)];
+                               var deleteID = (node.id === 'root' ? node.id : node.id.substr(1));
+                               delete this.stateHash[deleteID];
                        },
 
                        beforeclick: function(node) {
@@ -84,7 +85,7 @@ Ext.override(Ext.ux.state.TreePanel, {
                                this.isRestoringState = true;
                                        // get last selected node
                                for (var pageID in this.stateHash) {
-                                       var pageNode = this.getNodeById('p' + pageID);
+                                       var pageNode = this.getNodeById((pageID !== 'root' ? 'p' : '') + pageID);
                                        if (pageNode) {
                                                pageNode.on({
                                                        expand: {