mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
implement full_email attribute for et2-url-email with changed default of false
This commit is contained in:
parent
7a749a8f54
commit
89ebb61f76
@ -17,6 +17,62 @@ import {Et2UrlReadonly} from "./Et2UrlReadonly";
|
||||
*/
|
||||
export class Et2UrlEmailReadonly extends Et2UrlReadonly
|
||||
{
|
||||
/** @type {any} */
|
||||
static get properties()
|
||||
{
|
||||
return {
|
||||
...super.properties,
|
||||
/**
|
||||
* Show full email address if true otherwise show only name and put full address as statustext/tooltip
|
||||
*/
|
||||
full_email: {
|
||||
type: Boolean,
|
||||
},
|
||||
/**
|
||||
* Show icon to add email as contact to addressbook
|
||||
* @ToDo
|
||||
*/
|
||||
contact_plus: {
|
||||
type: Boolean,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
set value(val : string)
|
||||
{
|
||||
this._value = val;
|
||||
// check if we have a "name <email>" value and only show name
|
||||
if (!this.full_email && val && val.indexOf('<') !== -1)
|
||||
{
|
||||
const parts = val.split('<');
|
||||
if (parts[0])
|
||||
{
|
||||
super.statustext = parts[1].substring(0, parts[1].length-1);
|
||||
val = parts[0].trim();
|
||||
// remove quotes
|
||||
if ((val[0] === '"' || val[0] === "'" ) && val[0] === val.substr(-1))
|
||||
{
|
||||
val = val.substring(1, val.length-1);
|
||||
}
|
||||
}
|
||||
else // <email> --> email
|
||||
{
|
||||
super.statustext = '';
|
||||
val = parts[1].substring(0, val.length-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.statustext = '';
|
||||
}
|
||||
super.value = val;
|
||||
}
|
||||
|
||||
get value()
|
||||
{
|
||||
return super.value;
|
||||
}
|
||||
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
@ -28,9 +84,11 @@ export class Et2UrlEmailReadonly extends Et2UrlReadonly
|
||||
{
|
||||
attrs.onclick = () =>
|
||||
{
|
||||
if (IsEmail.EMAIL_PREG.exec(this.value))
|
||||
let email;
|
||||
if (IsEmail.EMAIL_PREG.exec(email=this.value) ||
|
||||
IsEmail.EMAIL_PREG.exec(email=this.value+' <'+this.statustext+'>'))
|
||||
{
|
||||
Et2UrlEmail.action(this.value);
|
||||
Et2UrlEmail.action(email);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,6 @@ const Et2WidgetMixin = (superClass) =>
|
||||
*/
|
||||
protected _widget_id : string = "";
|
||||
protected _dom_id : string = "";
|
||||
private statustext : string = "";
|
||||
|
||||
/**
|
||||
* TypeScript & LitElement ensure type correctness, so we can't have a string value like "$row_cont[disable_me]"
|
||||
@ -141,7 +140,11 @@ const Et2WidgetMixin = (superClass) =>
|
||||
/**
|
||||
* Tooltip which is shown for this element on hover
|
||||
*/
|
||||
statustext: {type: String, translate: true},
|
||||
statustext: {
|
||||
type: String,
|
||||
reflect: true,
|
||||
translate: true
|
||||
},
|
||||
|
||||
/**
|
||||
* The label of the widget
|
||||
@ -275,16 +278,27 @@ const Et2WidgetMixin = (superClass) =>
|
||||
|
||||
/**
|
||||
* supports legacy set_statustext
|
||||
* @deprecated use this.statustext
|
||||
* @param value
|
||||
*/
|
||||
set_statustext(value : string)
|
||||
{
|
||||
let oldValue = this.statustext;
|
||||
this.statustext = value;
|
||||
this.egw().tooltipBind(this, this.statustext);
|
||||
}
|
||||
|
||||
set statustext(value : string)
|
||||
{
|
||||
let oldValue = this.__statustext;
|
||||
this.__statustext = value;
|
||||
this.egw().tooltipBind(this, this.__statustext);
|
||||
this.requestUpdate("statustext", oldValue);
|
||||
}
|
||||
|
||||
get statustext() : string
|
||||
{
|
||||
return this.__statustext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper on this.disabled because legacy had it.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user