2022-03-10 09:15:59 +01:00
|
|
|
/**
|
|
|
|
* EGroupware eTemplate2 - Url r/o widget
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package api
|
|
|
|
* @link https://www.egroupware.org
|
|
|
|
* @author Ralf Becker
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
|
|
import {Et2Description} from "../Et2Description/Et2Description";
|
2023-02-13 21:28:48 +01:00
|
|
|
import {css, TemplateResult} from "@lion/core";
|
2022-03-10 09:15:59 +01:00
|
|
|
import {Et2Url} from "./Et2Url";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @customElement et2-url_ro
|
|
|
|
*/
|
|
|
|
export class Et2UrlReadonly extends Et2Description
|
|
|
|
{
|
|
|
|
static get styles()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
...super.styles,
|
|
|
|
css`
|
|
|
|
:host {
|
|
|
|
cursor: pointer;
|
|
|
|
color: #26537c;
|
|
|
|
}`
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
transformAttributes(attrs)
|
|
|
|
{
|
|
|
|
if (typeof attrs.onclick === 'undefined')
|
|
|
|
{
|
|
|
|
attrs.onclick = () =>
|
|
|
|
{
|
2023-02-13 21:28:48 +01:00
|
|
|
if(this.value)
|
2022-03-10 09:15:59 +01:00
|
|
|
{
|
|
|
|
Et2Url.action(this.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
super.transformAttributes(attrs);
|
|
|
|
}
|
2023-02-13 21:28:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Override parent render so we can have the special case where label is used as link text
|
|
|
|
*
|
|
|
|
* @returns {TemplateResult<1>}
|
|
|
|
* @protected
|
|
|
|
*/
|
|
|
|
protected render() : TemplateResult
|
|
|
|
{
|
|
|
|
if(this.label && !this.href && this.value)
|
|
|
|
{
|
|
|
|
// We have label & value, use label as link text
|
|
|
|
return this.wrapLink(this.value, this.label);
|
|
|
|
}
|
|
|
|
return super.render();
|
|
|
|
}
|
2022-03-10 09:15:59 +01:00
|
|
|
}
|
|
|
|
// @ts-ignore TypeScript is not recognizing that this is a LitElement
|
|
|
|
customElements.define("et2-url_ro", Et2UrlReadonly);
|