implement multiple attribute for et2-select reflecting it to selectbox

fixing TypeError set_multiple is not a function
This commit is contained in:
ralf 2022-03-10 15:48:27 +02:00
parent 0099b094b9
commit 9285b87a92

View File

@ -89,6 +89,29 @@ export class Et2Select extends Et2WidgetWithSelect
return this._inputNode;
}
static get properties()
{
return {
...super.properties,
/**
* Toggle between single and multiple selection
*/
multiple: {
type: Boolean,
reflect: true,
},
}
}
set_multiple(multi)
{
if (typeof multi !== 'boolean')
{
multi = multi && !(multi === 'false' || multi === '0');
}
this.multiple = multi;
}
/** @param {import('@lion/core').PropertyValues } changedProperties */
updated(changedProperties : PropertyValues)
{
@ -106,6 +129,12 @@ export class Et2Select extends Et2WidgetWithSelect
// Re-set value, the option for it may have just shown up
this._inputNode.value = this.modelValue || "";
}
// propagate multiple to selectbox
if (changedProperties.has('multiple'))
{
this._inputNode.multiple = this.multiple;
}
}
_emptyLabelTemplate() : TemplateResult