fix autoexpand for virtual nodes
authorMichael Spahn <m.spahn@metaways.de>
Thu, 20 Jul 2017 15:04:51 +0000 (17:04 +0200)
committerMichael Spahn <m.spahn@metaways.de>
Mon, 24 Jul 2017 10:04:11 +0000 (12:04 +0200)
Change-Id: I5c893722d407612fe4902690c1aa4bd4d4feea49
Reviewed-on: http://gerrit.tine20.com/customers/5273
Reviewed-by: Michael Spahn <m.spahn@metaways.de>
Tested-by: Michael Spahn <m.spahn@metaways.de>
tine20/Calendar/js/MainScreenCenterPanel.js
tine20/Tinebase/js/widgets/container/TreePanel.js
tine20/Tinebase/js/widgets/grid/FilterStructureTreePanel.js
tine20/Tinebase/js/widgets/tree/Loader.js

index c03373f..adf311b 100644 (file)
@@ -1492,7 +1492,8 @@ Tine.Calendar.MainScreenCenterPanel = Ext.extend(Ext.Panel, {
                 this.filterToolbar.setValue(store.proxy.jsonReader.jsonData.filter);
             }
             // update container tree
-            Tine.Tinebase.appMgr.get('Calendar').getMainScreen().getWestPanel().getContainerTreePanel().getFilterPlugin().setValue(store.proxy.jsonReader.jsonData.filter);
+            // why do we need this?
+            // Tine.Tinebase.appMgr.get('Calendar').getMainScreen().getWestPanel().getContainerTreePanel().getFilterPlugin().setValue(store.proxy.jsonReader.jsonData.filter);
             
             // update attendee filter grid
             Tine.Tinebase.appMgr.get('Calendar').getMainScreen().getWestPanel().getAttendeeFilter().setFilterValue(store.proxy.jsonReader.jsonData.filter);
index b7fad97..f57916c 100644 (file)
@@ -234,23 +234,37 @@ Ext.extend(Tine.widgets.container.TreePanel, Ext.tree.TreePanel, {
     },
 
     /**
-     *
-     * @param ids
+     * @param nodes
      */
     onVirtualNodesSelected: function (nodes) {
+        this.suspendEvents();
+
         if (0 === nodes.length) {
             return;
         }
 
-        this.getSelectionModel().suspendEvents();
+
+        var sm = this.getSelectionModel();
+
+        sm.suspendEvents();
+        sm.clearSelections(true);
 
         for (var i = 0; i < nodes.length; i++) {
-            this.getSelectionModel().select(nodes[i], null, 0 !== i);
-        }
+            var node = nodes[i];
 
-        this.getSelectionModel().resumeEvents();
+            if (sm.isSelected(node)) {
+                sm.lastSelNode = node;
+                continue;
+            }
+
+            sm.selNodes.push(node);
+            sm.selMap[node.id] = node;
+            sm.lastSelNode = node;
+            node.ui.onSelectedChange(true);
+        }
 
-        this.getSelectionModel().fireEvent('selectionchange', this.getSelectionModel(), nodes);
+        this.onFilterChange();
+        this.resumeEvents();
     },
 
     /**
@@ -686,6 +700,30 @@ Ext.extend(Tine.widgets.container.TreePanel, Ext.tree.TreePanel, {
         node.loaded = false;
     },
 
+    onFilterChange: function() {
+        // get filterToolbar
+        var ftb = this.filterPlugin.getGridPanel().filterToolbar;
+
+        // in case of filterPanel
+        ftb = ftb.activeFilterPanel ? ftb.activeFilterPanel : ftb;
+
+        // remove all ftb container and /toberemoved/ filters
+        ftb.supressEvents = true;
+        ftb.filterStore.each(function(filter) {
+            var field = filter.get('field');
+            // @todo find criteria what to remove
+            if (field === 'container_id' || field === 'attender' || field === 'path') {
+                ftb.deleteFilter(filter);
+            }
+        }, this);
+        ftb.supressEvents = false;
+
+        // set ftb filters according to tree selection
+        var containerFilter = this.getFilterPlugin().getFilter();
+        ftb.addFilter(new ftb.record(containerFilter));
+
+        ftb.onFiltertrigger();
+    },
 
     /**
      * called when tree selection changes
@@ -699,28 +737,8 @@ Ext.extend(Tine.widgets.container.TreePanel, Ext.tree.TreePanel, {
             this.filterPlugin.onFilterChange();
         }
         if (this.filterMode == 'filterToolbar' && this.filterPlugin) {
-            // get filterToolbar
-            var ftb = this.filterPlugin.getGridPanel().filterToolbar;
-            
-            // in case of filterPanel
-            ftb = ftb.activeFilterPanel ? ftb.activeFilterPanel : ftb;
-
-            // remove all ftb container and /toberemoved/ filters
-            ftb.supressEvents = true;
-            ftb.filterStore.each(function(filter) {
-                var field = filter.get('field');
-                // @todo find criteria what to remove
-                if (field === 'container_id' || field === 'attender' || field === 'path') {
-                    ftb.deleteFilter(filter);
-                }
-            }, this);
-            ftb.supressEvents = false;
-
-            // set ftb filters according to tree selection
-            var containerFilter = this.getFilterPlugin().getFilter();
-            ftb.addFilter(new ftb.record(containerFilter));
 
-            ftb.onFiltertrigger();
+            this.onFilterChange();
 
             // finally select the selected node, as filtertrigger clears all selections
             sm.suspendEvents();
index b0f5d51..723eea7 100644 (file)
@@ -182,6 +182,11 @@ Tine.widgets.grid.FilterStructureTreePanel = Ext.extend(Ext.tree.TreePanel, {
      */
     onFilterPanelActivate: function(filterToolbar, filterPanel) {
         var node = this.getNodeById(filterPanel.id);
+
+        if (this.getSelectionModel().isSelected(node)) {
+            return;
+        }
+
         if (node) {
             this.suspendEvents();
             node.select();
@@ -240,4 +245,4 @@ Tine.widgets.grid.FilterStructureTreePanel = Ext.extend(Ext.tree.TreePanel, {
             iconCls: filterPanel.app ? filterPanel.app.getIconCls() : 'leaf'
         };
     }
-});
\ No newline at end of file
+});
index 3422522..68c3a2a 100644 (file)
@@ -116,7 +116,7 @@ Tine.widgets.tree.Loader = Ext.extend(Ext.tree.TreeLoader, {
                 if (! child) {
                     child = {
                         'name': part,
-                        'id': part,
+                        'id': Ext.id(),
                         'children': [],
                         'leaf': false,
                         'editable': false,
@@ -178,7 +178,7 @@ Tine.widgets.tree.Loader = Ext.extend(Ext.tree.TreeLoader, {
      */
     findNodeByName: function (name, nodes) {
         var ret = false;
-        Ext.each(nodes, function (node, idx) {
+        Ext.each(nodes, function (node) {
             if (node && node.name && node.name == name && Ext.isArray(node.children)) {
                 ret = node;
             }