public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] ui: fix losing selection on store load
Date: Thu, 12 May 2022 14:23:52 +0200	[thread overview]
Message-ID: <20220512122352.2734887-1-d.csapak@proxmox.com> (raw)

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





             reply	other threads:[~2022-05-12 12:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 12:23 Dominik Csapak [this message]
2022-05-12 12:55 ` [pbs-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220512122352.2734887-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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