mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-23 05:41:02 +01:00
fix could not set forwarding address for vacation notice and get Et2Mail to deal with wrong/non-array values set from server-side
This commit is contained in:
parent
5ae371e02d
commit
5e42dc34de
@ -242,6 +242,18 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
|
||||
document.removeEventListener('focusin', this.handleLostFocus);
|
||||
}
|
||||
|
||||
set_value(_value)
|
||||
{
|
||||
if (!Array.isArray(_value))
|
||||
{
|
||||
this.value = parseEmailsString(_value, this.allowPlaceholder);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.value = _value;
|
||||
}
|
||||
}
|
||||
|
||||
willUpdate(changedProperties : PropertyValues)
|
||||
{
|
||||
super.willUpdate(changedProperties);
|
||||
@ -1131,5 +1143,20 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-ignore TypeScript is not recognizing that this widget is a LitElement
|
||||
customElements.define("et2-email", Et2Email);
|
||||
customElements.define("et2-email", Et2Email);
|
||||
|
||||
/**
|
||||
* Parse string that may contain multiple comma separated email addresses into an array
|
||||
*
|
||||
* @param {string} value
|
||||
* @returns {string[]}
|
||||
* @protected
|
||||
*/
|
||||
function parseEmailsString(value : string, allowPlaceholder = false) : string[]
|
||||
{
|
||||
if (!value) return [];
|
||||
let preg = allowPlaceholder ? IsEmail.EMAIL_PLACEHOLDER_PREG : IsEmail.EMAIL_PREG;
|
||||
// Trim line start / end anchors off validation regex, make global
|
||||
let regex = new RegExp(preg.toString().substring(2, preg.toString().length - 3), 'g');
|
||||
return value.match(regex);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user