[pbs-devel] [PATCH proxmox-backup] ui: fix losing selection on store load

Dominik Csapak d.csapak at proxmox.com
Thu May 12 14:23:52 CEST 2022


instead of using 'replaceChild', simply set the appropriate properties.
when using the 'nodeUpdate' (protected function of extjs, intended
to be overwritten) instead of the private 'updateNode', it will
be called when the properties change

this way, the treenode stays the same and we can keep the selection

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/NavigationTree.js | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/www/NavigationTree.js b/www/NavigationTree.js
index eea1d158..577310fd 100644
--- a/www/NavigationTree.js
+++ b/www/NavigationTree.js
@@ -130,9 +130,10 @@ Ext.define('PBS.store.NavigationStore', {
 Ext.define('CustomTreeListItem', {
     extend: 'Ext.list.TreeItem',
     xtype: 'qtiptreelistitem',
-    updateNode: function(node, oldNode) {
+
+    nodeUpdate: function(node, modifiedFieldNames) {
+	this.callParent(arguments);
 	const qtip = node ? node.get('qtip') : null;
-	this.callParent([node, oldNode]);
 	if (qtip) {
 	    this.element.dom.setAttribute('data-qtip', qtip);
 	} else {
@@ -261,17 +262,18 @@ Ext.define('PBS.view.main.NavigationTree', {
 		    iconCls = 'fa fa-database pmx-tree-icon-custom maintenance';
 		}
 
-		const child = {
-		    text: name,
-		    qtip,
-		    path: `DataStore-${name}`,
-		    iconCls,
-		    leaf: true,
-		};
 		if (getChildTextAt(j).localeCompare(name) !== 0) {
-		    list.insertChild(j, child);
+		    list.insertChild(j, {
+			text: name,
+			qtip,
+			path: `DataStore-${name}`,
+			iconCls,
+			leaf: true,
+		    });
 		} else {
-		    list.replaceChild(child, list.getChildAt(j));
+		    let oldChild = list.getChildAt(j);
+		    oldChild.set('qtip', qtip);
+		    oldChild.set('iconCls', iconCls);
 		}
 	    }
 
-- 
2.30.2






More information about the pbs-devel mailing list