diff --git a/api/js/etemplate/Et2Url/Et2UrlEmailReadonly.ts b/api/js/etemplate/Et2Url/Et2UrlEmailReadonly.ts index 3629bc6a28..2a1fd585b2 100644 --- a/api/js/etemplate/Et2Url/Et2UrlEmailReadonly.ts +++ b/api/js/etemplate/Et2Url/Et2UrlEmailReadonly.ts @@ -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 " 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 + { + 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); } } } diff --git a/api/js/etemplate/Et2Widget/Et2Widget.ts b/api/js/etemplate/Et2Widget/Et2Widget.ts index bad4f387bf..e9dcbb84b5 100644 --- a/api/js/etemplate/Et2Widget/Et2Widget.ts +++ b/api/js/etemplate/Et2Widget/Et2Widget.ts @@ -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. *