combogrid: add 'showClearTrigger' config

This allows one configure the clear trigger to be shown, even if
'allowBlank' is set false. This can be useful if one has a
non-editable combogrid where the value is set to something not
present in the store. Example: Match rule editing, one selects
a backup job to be match. If the backup job is removed and the match
rule edit window is opened again, then the old, deleted value cannot
be removed from the combogrid if there is no clear trigger.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Lukas Wagner 2024-02-28 11:00:58 +01:00 committed by Thomas Lamprecht
parent 43b978658e
commit 4bee6fb074

View File

@ -32,6 +32,7 @@ Ext.define('Proxmox.form.ComboGrid', {
notFoundIsValid: false,
deleteEmpty: false,
errorHeight: 100,
showClearTrigger: false,
},
// needed to trigger onKeyUp etc.
@ -54,7 +55,10 @@ Ext.define('Proxmox.form.ComboGrid', {
setValue: function(value) {
let me = this;
let empty = Ext.isArray(value) ? !value.length : !value;
me.triggers.clear.setVisible(!empty && me.allowBlank);
me.triggers.clear.setVisible(
(!empty && me.allowBlank) ||
(!empty && me.showClearTrigger),
);
return me.callParent([value]);
},