* [pve-devel] applied: [PATCH] combo grid: load: rework auto-selection and validity logic
@ 2021-06-07 16:14 Thomas Lamprecht
0 siblings, 0 replies; only message in thread
From: Thomas Lamprecht @ 2021-06-07 16:14 UTC (permalink / raw)
To: pve-devel
We do not want to trigger an autoSelect if there's a value set, even
if it isn't found in the store, as that hides the fact that an (now)
invalid valid is configured from the user, which can be confusing if
something is not working, as when editing an object it seems like a
valid value is selected.
Further, if a value is set we mark the field as invalid from the
start, at least if it's neither disabled nor allowed to have a
value which is does not exists in the backing store.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
As it's a change in a rather tricky place for something where we had a
few "fixes" already it's something which gave me a slight headache, but
IMO the shift in semantics makes it more friendly to use as developer,
and makes autoSelect behave more like one would expect, i.e., autoSelect
if nothing is selected (avoiding a `me.autoSelect = me.isCreate` logic)
src/form/ComboGrid.js | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/form/ComboGrid.js b/src/form/ComboGrid.js
index af04559..923a55a 100644
--- a/src/form/ComboGrid.js
+++ b/src/form/ComboGrid.js
@@ -445,15 +445,19 @@ Ext.define('Proxmox.form.ComboGrid', {
}
if (!found) {
- let rec = me.store.first();
- if (me.autoSelect && rec && rec.data) {
- def = rec.data[me.valueField];
- me.setValue(def, true);
- } else if (!me.allowBlank && !(Ext.isArray(def) ? def.length : def)) {
- me.setValue(def);
- if (!me.notFoundIsValid && !me.isDisabled()) {
- me.markInvalid(me.blankText);
+ if (!(Ext.isArray(def) ? def.length : def)) {
+ let rec = me.store.first();
+ if (me.autoSelect && rec && rec.data) {
+ def = rec.data[me.valueField];
+ me.setValue(def, true);
+ } else if (!me.allowBlank) {
+ me.setValue(def);
+ if (!me.isDisabled()) {
+ me.markInvalid(me.blankText);
+ }
}
+ } else if (!me.notFoundIsValid && !me.isDisabled()) {
+ me.markInvalid(gettext('Invalid Value'));
}
}
} else {
--
2.30.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-07 16:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07 16:14 [pve-devel] applied: [PATCH] combo grid: load: rework auto-selection and validity logic Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox