]> git.proxmox.com Git - pve-manager.git/commitdiff
update leaf nodes instead of removing / readding them
authorEmmanuel Kasper <e.kasper@proxmox.com>
Mon, 14 Mar 2016 09:31:43 +0000 (10:31 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 14 Mar 2016 16:02:46 +0000 (17:02 +0100)
if the selected node has its status changed between stop &
running, the node was removed and then readded
during the remove / add process the 'selected' status of the node
was lost if it has one

instead of deleting / readding the node, we update now its content
this was the default behaviour for server nodes, but not for leaf nodes

this fixes a graphical bug where starting/stopping a VM/container would lose
the current selection in the ressource tree

www/manager6/tree/ResourceTree.js

index 711a38616a662e10fd15dec7d54e9da3908ba75d..c81d9c91880776a96d56404e48281ed321c05a54 100644 (file)
@@ -250,22 +250,19 @@ Ext.define('PVE.tree.ResourceTree', {
                        // fixme: also test filterfn()?
                    }
 
-                   if (!item || changed) {
+                   if (changed) {
+                       olditem.beginEdit();
+                       //console.log("REM UPDATE UID: " + key + " ITEM " + item.data.running);
+                       var info = olditem.data;
+                       Ext.apply(info, item.data);
+                       me.setIconCls(info);
+                       olditem.commit();
+                   }
+                   if (!item && olditem.isLeaf()) {
                        //console.log("REM UID: " + key + " ITEM " + olditem.data.id);
-                       if (olditem.isLeaf()) {
-                           delete index[key];
-                           var parentNode = olditem.parentNode;
-                           parentNode.removeChild(olditem, true);
-                       } else {
-                           if (item && changed) {
-                               olditem.beginEdit();
-                               //console.log("REM UPDATE UID: " + key + " ITEM " + item.data.running);
-                               var info = olditem.data;
-                               Ext.apply(info, item.data);
-                               me.setIconCls(info);
-                               olditem.commit();
-                           }
-                       }
+                       delete index[key];
+                       var parentNode = olditem.parentNode;
+                       parentNode.removeChild(olditem, true);
                    }
                }
            }
@@ -303,6 +300,7 @@ Ext.define('PVE.tree.ResourceTree', {
                me.selectById(lastsel.data.id);
            }
 
+           // on first tree load set the selection from the stateful provider
            if (!pdata.updateCount) {
                rootnode.collapse();
                rootnode.expand();