form: combo grid: clarify that showClearTrigger cannot actively hide them

As getting a good setting name is a bit hard here, the current one
might me interpreted such that setting it to false will always hide
the trigger, but that's not the case, this is mostly a "force show
trigger even if allowBlank is set to false", and that's a bit of a
long name ;-)
So just add a comment and reevaluate if this really causes confusion.

While at it simplify the boolean expression to make it shorter and
easier to read.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2024-02-28 11:34:42 +01:00
parent 4bee6fb074
commit 36d167d629

View File

@ -32,6 +32,8 @@ Ext.define('Proxmox.form.ComboGrid', {
notFoundIsValid: false, notFoundIsValid: false,
deleteEmpty: false, deleteEmpty: false,
errorHeight: 100, errorHeight: 100,
// NOTE: the trigger will always be shown if allowBlank is true, setting showClearTrigger
// to false cannot change that
showClearTrigger: false, showClearTrigger: false,
}, },
@ -55,10 +57,7 @@ Ext.define('Proxmox.form.ComboGrid', {
setValue: function(value) { setValue: function(value) {
let me = this; let me = this;
let empty = Ext.isArray(value) ? !value.length : !value; let empty = Ext.isArray(value) ? !value.length : !value;
me.triggers.clear.setVisible( me.triggers.clear.setVisible(!empty && (me.allowBlank || me.showClearTrigger));
(!empty && me.allowBlank) ||
(!empty && me.showClearTrigger),
);
return me.callParent([value]); return me.callParent([value]);
}, },