ComboGrid: correctly set/mark multiSelect fields

in fields with 'multiSelect: true', we get an array as value instead
of a string, but a check of !![] results in true (since an array
is an object), so we have to explicitely check for arraylength
in 'setValue' (for correctly showing the trigger) and in the
load handler (to not set an empty field wrongfully to invalid)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2019-11-25 11:04:57 +01:00 committed by Thomas Lamprecht
parent 013cbd6425
commit f32aa3df74

View File

@ -52,7 +52,8 @@ Ext.define('Proxmox.form.ComboGrid', {
setValue: function(value) {
var me = this;
me.triggers.clear.setVisible(!!value && me.allowBlank);
let empty = Ext.isArray(value) ? !value.length : !value;
me.triggers.clear.setVisible(!empty && me.allowBlank);
return me.callParent([value]);
},
@ -458,7 +459,7 @@ Ext.define('Proxmox.form.ComboGrid', {
if (me.autoSelect && rec && rec.data) {
def = rec.data[me.valueField];
me.setValue(def, true);
} else {
} else if (!me.allowBlank && ((Ext.isArray(def) && def.length) || def)) {
me.setValue(def);
if (!me.notFoundIsValid) {
me.markInvalid(gettext('Invalid Value'));