From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] ui: storage: show no-keeps hint exactly when needed
Date: Tue, 24 Nov 2020 15:31:36 +0100 [thread overview]
Message-ID: <20201124143136.29247-1-f.ebner@proxmox.com> (raw)
extracting the logic from the previous checkbox listener into a function, which
is also called on field changes and once in afterrender. Calling it initially
makes sure the hint is also displayed at the beginning when editing a storage
with no retention options configured, and the initial disabling of the input
fields for the isCreate case now also happens through that call.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
Not too happy about the function name, but couldn't come up with
anything better.
www/manager6/storage/Base.js | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index 6113743d..4dd84b87 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -81,6 +81,18 @@ Ext.define('PVE.panel.StoragePruneInputPanel', {
return options;
},
+ updateComponents: function() {
+ let panel = this;
+
+ let keepAll = panel.down('proxmoxcheckbox[name=keep-all]').getValue();
+ let anyValue = false;
+ panel.query('pmxPruneKeepField').forEach(field => {
+ anyValue = anyValue || field.getValue() !== null;
+ field.setDisabled(keepAll);
+ });
+ panel.down('component[name=no-keeps-hint]').setHidden(anyValue || keepAll);
+ },
+
listeners: {
afterrender: function(panel) {
if (panel.needMask) {
@@ -89,12 +101,14 @@ Ext.define('PVE.panel.StoragePruneInputPanel', {
gettext('Backup content type not available for this storage.'),
);
} else if (panel.isCreate) {
- panel.query('pmxPruneKeepField').forEach(field => {
- field.setDisabled(true);
- });
panel.down('proxmoxcheckbox[name=keep-all]').setValue(true);
}
panel.down('component[name=pbs-hint]').setHidden(!panel.isPBS);
+
+ panel.query('pmxPruneKeepField').forEach(field => {
+ field.on('change', panel.updateComponents, panel);
+ });
+ panel.updateComponents();
},
},
@@ -105,12 +119,7 @@ Ext.define('PVE.panel.StoragePruneInputPanel', {
listeners: {
change: function(field, newValue) {
let panel = field.up('pveStoragePruneInputPanel');
- let anyValue = false;
- panel.query('pmxPruneKeepField').forEach(field => {
- anyValue = anyValue || field.getValue() !== null;
- field.setDisabled(newValue);
- });
- panel.down('component[name=no-keeps-hint]').setHidden(anyValue || newValue);
+ panel.updateComponents();
},
},
},
--
2.20.1
next reply other threads:[~2020-11-24 14:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 14:31 Fabian Ebner [this message]
2020-11-24 14:47 ` [pve-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=20201124143136.29247-1-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-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