Add Et2SelectEmail.full_email property. Set to true when you need to see the full, original value

This commit is contained in:
nathan 2022-07-19 13:18:51 -06:00
parent b20f57d5ba
commit 2bcebeed42
2 changed files with 24 additions and 4 deletions

View File

@ -46,9 +46,14 @@ export class Et2SelectEmail extends Et2Select
...super.properties,
/**
* Allow drag and drop tags
* Allow drag and drop tags between two or more Et2SelectEmail widgets
*/
allowDragAndDrop: {type: Boolean}
allowDragAndDrop: {type: Boolean},
/**
* Show the full, original value email address under all circumstances, rather than the contact name for known contacts
*/
full_email: {type: Boolean}
}
}
@ -61,6 +66,7 @@ export class Et2SelectEmail extends Et2Select
this.editModeEnabled = true;
this.allowDragAndDrop = false;
this.multiple = true;
this.full_email = false;
this.defaultValidators.push(new IsEmail());
}
@ -159,6 +165,7 @@ export class Et2SelectEmail extends Et2Select
protected _createTagNode(item)
{
let tag = super._createTagNode(item);
tag.full_email = this.full_email;
if(!this.readonly && this.allowFreeEntries && this.allowDragAndDrop)
{
let dragTranslate = {x:0,y:0};

View File

@ -80,7 +80,13 @@ export class Et2EmailTag extends Et2Tag
contact_plus: {
type: Boolean,
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 the email
*/
full_email: {type: Boolean}
}
}
@ -88,6 +94,7 @@ export class Et2EmailTag extends Et2Tag
{
super(...args);
this.contact_plus = true;
this.full_email = false;
this.handleMouseEnter = this.handleMouseEnter.bind(this);
this.handleMouseLeave = this.handleMouseLeave.bind(this);
this.handleClick = this.handleClick.bind(this);
@ -147,7 +154,7 @@ export class Et2EmailTag extends Et2Tag
{
this._contactPlusNode.classList.add("contact_plus_contact");
// Add name in if missing
if(data.n_fn && !this.splitEmail(this.value).name)
if(!this.full_email && data.n_fn && !this.splitEmail(this.value).name)
{
// Append current value as email, data may have work & home email in it
this.textContent = data.n_fn + " <" + this.value + ">"
@ -223,6 +230,12 @@ export class Et2EmailTag extends Et2Tag
*/
set textContent(new_content)
{
if(this.full_email)
{
super.textContent = new_content;
return;
}
const split = this.splitEmail(new_content);
super.textContent = split.name || split.email;