0008796: folder tree always scrolls to top on copying a mail into a folder
authorAlexander Stintzing <a.stintzing@metaways.de>
Tue, 20 Aug 2013 12:59:23 +0000 (14:59 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 22 Aug 2013 13:16:37 +0000 (15:16 +0200)
When having a large folder tree, with a folder at a position to have to scroll
to, copying a mail into that folder always forces the tree to scroll to top.

https://forge.tine20.org/mantisbt/view.php?id=8796

Change-Id: I134baaa92112453ed1490255f1ac99b73707d838
Reviewed-on: https://gerrit.tine20.org/tine20/2267
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/js/widgets/mainscreen/WestPanel.js
tine20/Tinebase/js/widgets/tree/FilterPlugin.js

index 2a8b4c4..029d712 100644 (file)
@@ -197,9 +197,12 @@ Ext.extend(Tine.widgets.mainscreen.WestPanel, Ext.ux.Portal, {
      */
     getContainerTreePanel: function() {
         var panelName = this.app.getMainScreen().getActiveContentType() + 'TreePanel';
-        if(!this[panelName]) {
-            if(Tine[this.app.appName].hasOwnProperty(panelName)) this[panelName] = new Tine[this.app.appName][panelName]({app: this.app});
-            else this[panelName] = new Tine.widgets.persistentfilter.PickerPanel({app: this.app});
+        if (! this[panelName]) {
+            if (Tine[this.app.appName].hasOwnProperty(panelName)) {
+                this[panelName] = new Tine[this.app.appName][panelName]({app: this.app});
+            } else {
+                this[panelName] = new Tine.widgets.persistentfilter.PickerPanel({app: this.app});
+            }
             this[panelName].on('click', function (node, event) {
                 if(node != this.lastClickedNode) {
                     this.lastClickedNode = node;
index a43406f..d1f9b34 100644 (file)
@@ -112,9 +112,12 @@ Tine.widgets.tree.FilterPlugin = Ext.extend(Tine.widgets.grid.FilterPlugin, {
             
             // save west panel scrolling position so we can restore it after selecting nodes
             if (this.treePanel.app.getMainScreen().getWestPanel().body) {
-                this.leftPanelScrollTop = this.treePanel.app.getMainScreen().getWestPanel().body.getScroll().top;
+                var scroller = Ext.get('treecards').dom.parentElement;
+                if (scroller) {
+                    this.leftPanelScrollTop = scroller.scrollTop;
+                }
             }
-            
+
             this.treePanel.getSelectionModel().suspendEvents();
             this.selectValue(filter.value);
         }, this);
@@ -133,6 +136,7 @@ Tine.widgets.tree.FilterPlugin = Ext.extend(Tine.widgets.grid.FilterPlugin, {
             }
             
             var treePath = this.treePanel.getTreePath(value.path);
+            
             this.selectPath.call(this.treePanel, treePath, null, function() {
                 // mark this expansion as done and check if all are done
                 value.isExpanded = true;
@@ -148,16 +152,19 @@ Tine.widgets.tree.FilterPlugin = Ext.extend(Tine.widgets.grid.FilterPlugin, {
                             if (this.lastFocusEl) {
                                 var scroller = Ext.fly(this.lastFocusEl).up('div[class$=-scroller]'),
                                     scrollTop = scroller ? scroller.dom.scrollTop : null;
+                                    
                                 // TODO: is this needed (the element is already focused, atm. IE breaks (https://forge.tine20.org/mantisbt/view.php?id=6916))?
                                 if(!Ext.isIE) {
                                     Ext.fly(this.lastFocusEl).focus();
                                 }
                                 
-                                if (scrollTop) scroller.dom.scrollTop = scrollTop;
+                                if (scrollTop) {
+                                    scroller.dom.scrollTop = scrollTop;
+                                }
                             }
                             
                             if (this.leftPanelScrollTop) {
-                                this.treePanel.app.getMainScreen().getWestPanel().body.dom.scrollTop = this.leftPanelScrollTop;
+                                Ext.get('treecards').dom.parentElement.scrollTop = this.leftPanelScrollTop;
                             }
                         } catch (e) {}
                     }).defer(10, this);
@@ -179,6 +186,7 @@ Tine.widgets.tree.FilterPlugin = Ext.extend(Tine.widgets.grid.FilterPlugin, {
         attr = attr || 'id';
         var keys = path.split(this.pathSeparator),
             v = keys.pop();
+            
         if(keys.length > 1){
             var f = function(success, node){
                 if(success && node) {