all lists on 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 widget-toolkit 1/1] combogrid: initialze value with [] by default
Date: Wed, 19 Jul 2023 14:11:09 +0200	[thread overview]
Message-ID: <20230719121112.229074-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20230719121112.229074-1-d.csapak@proxmox.com>

we have to initialize the value of a combogrid to something (else extjs
does not initialize everything in the object *sometimes* for yet unknown
reasons), but the empty string is wrong.

we already have at least two places where we set the default value to []
(namely NodeSelector and ha GroupSelector) with the comment:

 // set default value to empty array, else it inits it with
 // null and after the store load it is an empty array,
 // triggering dirtychange

so it makes sense to always set it to that by default. This only ever is
relevant when the combogrid has `allowBlank: true`, since if it does not
it's either invalid (and thus "dirty") or it has a selected value anyway

this should make the manual setting of

 value: [],

unnecessary in the child classes. We can even remove it direcly in the
NetworkSelector.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/form/ComboGrid.js       | 2 +-
 src/form/NetworkSelector.js | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/form/ComboGrid.js b/src/form/ComboGrid.js
index 55dee7e..6338a3a 100644
--- a/src/form/ComboGrid.js
+++ b/src/form/ComboGrid.js
@@ -400,7 +400,7 @@ Ext.define('Proxmox.form.ComboGrid', {
 	    matchFieldWidth: false,
 	});
 
-	Ext.applyIf(me, { value: '' }); // hack: avoid ExtJS validate() bug
+	Ext.applyIf(me, { value: [] }); // hack: avoid ExtJS validate() bug
 
 	Ext.applyIf(me.listConfig, { width: 400 });
 
diff --git a/src/form/NetworkSelector.js b/src/form/NetworkSelector.js
index 86d394d..30a1cd4 100644
--- a/src/form/NetworkSelector.js
+++ b/src/form/NetworkSelector.js
@@ -45,10 +45,6 @@ Ext.define('Proxmox.form.NetworkSelector', {
 	    networkSelectorStore.load();
 	}
     },
-    // set default value to empty array, else it inits it with
-    // null and after the store load it is an empty array,
-    // triggering dirtychange
-    value: [],
     valueField: 'cidr',
     displayField: 'cidr',
     store: {
-- 
2.30.2





  reply	other threads:[~2023-07-19 12:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19 12:11 [pve-devel] [PATCH widget-toolkit/manager] improve combogrid default value handling Dominik Csapak
2023-07-19 12:11 ` Dominik Csapak [this message]
2023-11-14  8:04   ` [pve-devel] applied: [PATCH widget-toolkit 1/1] combogrid: initialze value with [] by default Thomas Lamprecht
2023-07-19 12:11 ` [pve-devel] [PATCH manager 1/3] ui: ipset: make ip/cidr required Dominik Csapak
2023-07-19 12:11 ` [pve-devel] [PATCH manager 2/3] ui: don't set the default value of combogrids to '' Dominik Csapak
2023-07-19 12:11 ` [pve-devel] [PATCH manager 3/3] ui: don't set the default value of combogrids to [] Dominik Csapak
2023-07-19 12:22 ` [pve-devel] [PATCH widget-toolkit/manager] improve combogrid default value handling Fabian Grünbichler
2023-11-14 15:52 ` [pve-devel] applied-series: " 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=20230719121112.229074-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal