From b3ea3c89cfe826fdbce69a4f9be7b24e7cc8fd5a Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 11 Apr 2023 18:19:17 +0200 Subject: [PATCH] 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 --- admin/templates/default/mailaccount.xet | 4 ++-- api/js/etemplate/Et2Select/Et2SelectEmail.ts | 9 +++++++++ api/js/etemplate/Et2Select/Tag/Et2EmailTag.ts | 17 +++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/admin/templates/default/mailaccount.xet b/admin/templates/default/mailaccount.xet index 33a3b504d3..fc7eda81cd 100644 --- a/admin/templates/default/mailaccount.xet +++ b/admin/templates/default/mailaccount.xet @@ -259,12 +259,12 @@ - + - + diff --git a/api/js/etemplate/Et2Select/Et2SelectEmail.ts b/api/js/etemplate/Et2Select/Et2SelectEmail.ts index f06e6024d0..45456a9674 100644 --- a/api/js/etemplate/Et2Select/Et2SelectEmail.ts +++ b/api/js/etemplate/Et2Select/Et2SelectEmail.ts @@ -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(); diff --git a/api/js/etemplate/Et2Select/Tag/Et2EmailTag.ts b/api/js/etemplate/Et2Select/Tag/Et2EmailTag.ts index f13d63a783..9e1a6a70f6 100644 --- a/api/js/etemplate/Et2Select/Tag/Et2EmailTag.ts +++ b/api/js/etemplate/Et2Select/Tag/Et2EmailTag.ts @@ -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;