implement onlyEmail attribute for et2-select-mail to only display email address, even if we have a full rfc822 address and use it for aliases and forwards in admin mail

This commit is contained in:
ralf 2023-04-11 18:19:17 +02:00
parent f957656f92
commit b3ea3c89cf
3 changed files with 26 additions and 4 deletions

View File

@ -259,12 +259,12 @@
</row>
<row>
<et2-description for="mailAlternateAddress" value="Alternate email address"></et2-description>
<et2-select-email id="mailAlternateAddress" allowFreeEntries="true" multiple="true" autocompleteUrl="" fullEmail="true"></et2-select-email>
<et2-select-email id="mailAlternateAddress" allowFreeEntries="true" multiple="true" autocompleteUrl="" onlyEmail="true"></et2-select-email>
<et2-description></et2-description>
</row>
<row disabled="@no_forward_available">
<et2-description for="mailForwardingAddress" value="Forward email's to"></et2-description>
<et2-select-email id="mailForwardingAddress" allowFreeEntries="true" multiple="true" autocompleteUrl="" fullEmail="true"></et2-select-email>
<et2-select-email id="mailForwardingAddress" allowFreeEntries="true" multiple="true" autocompleteUrl="" onlyEmail="true"></et2-select-email>
<et2-vbox>
<et2-checkbox label="Forward only" id="deliveryMode" onchange="if (widget.getValue()) et2_dialog.alert('Forward only disables IMAP mailbox / storing of mails and just forwards them to given address.','Forward only');" selectedValue="forwardOnly"></et2-checkbox>
<et2-checkbox label="Allow users to change forwards" id="acc_user_forward"></et2-checkbox>

View File

@ -66,6 +66,13 @@ export class Et2SelectEmail extends Et2Select
*/
includeLists: {type: Boolean},
/**
* If the email is a contact, we normally show the contact name instead of the email.
* Set to true to turn this off and always show just the email
* Mutually exclusive with fullEmail!
*/
onlyEmail: {type: Boolean},
/**
* Show the full, original value email address under all circumstances, rather than the contact name for known contacts
*/
@ -85,6 +92,7 @@ export class Et2SelectEmail extends Et2Select
this.includeLists = false;
this.multiple = false;
this.fullEmail = false;
this.onlyEmail = false;
this.defaultValidators.push(new IsEmail(this.allowPlaceholder));
}
@ -190,6 +198,7 @@ export class Et2SelectEmail extends Et2Select
let tag = super._createTagNode(item);
tag.fullEmail = this.fullEmail;
tag.onlyEmail = this.onlyEmail;
// Re-set after setting fullEmail as that can change what we show
tag.textContent = item.getTextLabel().trim();

View File

@ -72,6 +72,13 @@ export class Et2EmailTag extends Et2Tag
reflect: true,
},
/**
* If the email is a contact, we normally show the contact name instead of the email.
* Set to true to turn this off and always show just the email
* Mutually exclusive with fullEmail!
*/
onlyEmail: {type: Boolean},
/**
* If the email is a contact, we normally show the contact name instead of the email.
* Set to true to turn this off and always show the email
@ -85,6 +92,7 @@ export class Et2EmailTag extends Et2Tag
super(...args);
this.contactPlus = true;
this.fullEmail = false;
this.onlyEmail = false;
this.handleMouseEnter = this.handleMouseEnter.bind(this);
this.handleMouseLeave = this.handleMouseLeave.bind(this);
this.handleClick = this.handleClick.bind(this);
@ -184,12 +192,17 @@ export class Et2EmailTag extends Et2Tag
{
let content = this.value;
// If there's a name, just show the name, otherwise show the email
if(Et2EmailTag.email_cache[this.value])
if(!this.onlyEmail && Et2EmailTag.email_cache[this.value])
{
// Append current value as email, data may have work & home email in it
content = (Et2EmailTag.email_cache[this.value]?.n_fn || "") + " <" + this.value + ">"
}
if(!this.fullEmail)
if (this.onlyEmail)
{
const split = this.splitEmail(content);
content = split.email || this.value;
}
else if(!this.fullEmail)
{
const split = this.splitEmail(content);
content = split.name || split.email;