public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] ui: fix losing selection on store load
@ 2022-05-12 12:23 Dominik Csapak
  2022-05-12 12:55 ` [pbs-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2022-05-12 12:23 UTC (permalink / raw)
  To: pbs-devel

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@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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup] ui: fix losing selection on store load
  2022-05-12 12:23 [pbs-devel] [PATCH proxmox-backup] ui: fix losing selection on store load Dominik Csapak
@ 2022-05-12 12:55 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2022-05-12 12:55 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

Am 5/12/22 um 14:23 schrieb Dominik Csapak:
> 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@proxmox.com>
> ---
>  www/NavigationTree.js | 24 +++++++++++++-----------
>  1 file changed, 13 insertions(+), 11 deletions(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-12 12:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 12:23 [pbs-devel] [PATCH proxmox-backup] ui: fix losing selection on store load Dominik Csapak
2022-05-12 12:55 ` [pbs-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal