From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 3/3] ui: DataStoreContent: keep selection and expansion on reload
Date: Thu, 23 Jul 2020 13:03:51 +0200 [thread overview]
Message-ID: <20200723110351.31882-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20200723110351.31882-1-d.csapak@proxmox.com>
when clicking reload, we keep the existing selection
(if it still exists), and the previous expanded elements expanded
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
www/DataStoreContent.js | 42 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/www/DataStoreContent.js b/www/DataStoreContent.js
index e32c616..5f407e9 100644
--- a/www/DataStoreContent.js
+++ b/www/DataStoreContent.js
@@ -141,6 +141,30 @@ Ext.define('PBS.DataStoreContent', {
let groups = this.getRecordGroups(records);
+ let selected;
+ let expanded = {};
+
+ view.getSelection().some(function(item) {
+ let id = item.data.text;
+ if (item.data.leaf) {
+ id = item.parentNode.data.text + id;
+ }
+ selected = id;
+ return true;
+ });
+
+ view.getRootNode().cascadeBy({
+ before: item => {
+ if (item.isExpanded() && !item.data.leaf) {
+ let id = item.data.text;
+ expanded[id] = true;
+ return true;
+ }
+ return false;
+ },
+ after: () => {},
+ });
+
for (const item of records) {
let group = item.data["backup-type"] + "/" + item.data["backup-id"];
let children = groups[group].children;
@@ -152,6 +176,8 @@ Ext.define('PBS.DataStoreContent', {
data.cls = 'no-leaf-icons';
data.matchesFilter = true;
+ data.expanded = !!expanded[data.text];
+
data.children = [];
for (const file of data.files) {
file.text = file.filename,
@@ -166,7 +192,7 @@ Ext.define('PBS.DataStoreContent', {
}
let children = [];
- for (const [_key, group] of Object.entries(groups)) {
+ for (const [name, group] of Object.entries(groups)) {
let last_backup = 0;
let crypt = {
none: 0,
@@ -189,6 +215,7 @@ Ext.define('PBS.DataStoreContent', {
group.matchesFilter = true;
crypt.count = group.count;
group['crypt-mode'] = PBS.Utils.calculateCryptMode(crypt);
+ group.expanded = !!expanded[name];
children.push(group);
}
@@ -196,6 +223,19 @@ Ext.define('PBS.DataStoreContent', {
expanded: true,
children: children
});
+
+ if (selected !== undefined) {
+ let selection = view.getRootNode().findChildBy(function(item) {
+ let id = item.data.text;
+ if (item.data.leaf) {
+ id = item.parentNode.data.text + id;
+ }
+ return selected === id;
+ }, undefined, true);
+ view.setSelection(selection);
+ view.getView().focusRow(selection);
+ }
+
Proxmox.Utils.setErrorMask(view, false);
if (view.getStore().getFilters().length > 0) {
let searchBox = me.lookup("searchbox");
--
2.20.1
next prev parent reply other threads:[~2020-07-23 11:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-23 11:03 [pbs-devel] [PATCH proxmox-backup 1/3] ui: rework DataStore content Panel Dominik Csapak
2020-07-23 11:03 ` [pbs-devel] [PATCH proxmox-backup 2/3] ui: add search box to DataStore content Dominik Csapak
2020-07-23 11:03 ` Dominik Csapak [this message]
2020-07-27 10:57 ` [pbs-devel] applied: [PATCH proxmox-backup 1/3] ui: rework DataStore content Panel Dietmar Maurer
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=20200723110351.31882-3-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