public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 1/1] ui: ceph: pool: don't always show advanced fields on create
Date: Fri, 10 Mar 2023 15:08:08 +0100	[thread overview]
Message-ID: <20230310140808.2245916-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20230310140808.2245916-1-d.csapak@proxmox.com>

since the ruleselector is not allowed to be empty, but the loading of
the rules is not instant, the validity change will trigger before the
load was finished. Since it is in the advanced section, it will be
opened everytime instead of only when there is an invalid value.

This patch fixes that by temporarily setting 'allowBlank' to true
until the store is loaded, and then it revalidates the field.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
note: this patch requires the previous widget-toolkit one to work
 www/manager6/ceph/Pool.js | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js
index a1f008d1a..f7a4d9bae 100644
--- a/www/manager6/ceph/Pool.js
+++ b/www/manager6/ceph/Pool.js
@@ -484,6 +484,10 @@ Ext.define('PVE.form.CephRuleSelector', {
 	if (!me.nodename) {
 	    throw "no nodename given";
 	}
+
+	me.originalAllowBlank = me.allowBlank;
+	me.allowBlank = true;
+
 	Ext.apply(me, {
 	    store: {
 		fields: ['name'],
@@ -492,13 +496,17 @@ Ext.define('PVE.form.CephRuleSelector', {
 		    type: 'proxmox',
 		    url: `/api2/json/nodes/${me.nodename}/ceph/rules`,
 		},
-		autoLoad: me.isCreate ? {
+		autoLoad: {
 		    callback: (records, op, success) => {
-			if (success && records.length > 0) {
+			if (me.isCreate && success && records.length > 0) {
 			    me.select(records[0]);
 			}
+
+			me.allowBlank = me.originalAllowBlank;
+			delete me.originalAllowBlank;
+			me.validate();
 		    },
-		} : true,
+		},
 	    },
 	});
 
-- 
2.30.2





  reply	other threads:[~2023-03-10 14:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10 14:08 [pve-devel] [PATCH widget-toolkit 1/1] inputpanel: improve validitychange check for advanced fields Dominik Csapak
2023-03-10 14:08 ` Dominik Csapak [this message]
2023-03-11 16:39   ` [pve-devel] applied: [PATCH manager 1/1] ui: ceph: pool: don't always show advanced fields on create Thomas Lamprecht
2023-03-10 14:45 ` [pve-devel] [PATCH widget-toolkit 1/1] inputpanel: improve validitychange check for advanced fields Aaron Lauterer
2023-03-11 16:33 ` [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=20230310140808.2245916-2-d.csapak@proxmox.com \
    --to=d.csapak@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal