mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-29 11:23:54 +01:00
Fix missing Et2Image label
This commit is contained in:
parent
49d40c18e8
commit
6ed888a80e
@ -34,6 +34,17 @@ export class Et2Image extends Et2Widget(LitElement) implements et2_IDetachedDOM
|
|||||||
static get properties()
|
static get properties()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
...super.properties,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The label of the image
|
||||||
|
* Actually not used as label, but we put it as title
|
||||||
|
* Added here as there's no Lion parent
|
||||||
|
*/
|
||||||
|
label: {
|
||||||
|
type: String,
|
||||||
|
translate: true
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image
|
* Image
|
||||||
@ -77,8 +88,9 @@ export class Et2Image extends Et2Widget(LitElement) implements et2_IDetachedDOM
|
|||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.src = "";
|
this.src = "";
|
||||||
this.default_src = egw?.image("help");
|
this.default_src = "";
|
||||||
this.href = "";
|
this.href = "";
|
||||||
|
this.label = "";
|
||||||
this.extra_link_target = "_self";
|
this.extra_link_target = "_self";
|
||||||
this.extra_link_popup = "";
|
this.extra_link_popup = "";
|
||||||
this.expose_view = false;
|
this.expose_view = false;
|
||||||
@ -94,37 +106,26 @@ export class Et2Image extends Et2Widget(LitElement) implements et2_IDetachedDOM
|
|||||||
{
|
{
|
||||||
return html`
|
return html`
|
||||||
<img ${this.id ? html`id="${this.id}"` : ''}
|
<img ${this.id ? html`id="${this.id}"` : ''}
|
||||||
src="${this.src || this.default_src}"
|
src="${this.parse_href(this.src) || this.parse_href(this.default_src)}"
|
||||||
alt="${this.label}"
|
alt="${this.label}"
|
||||||
title="${this.statustext || this.label}"
|
title="${this.statustext || this.label}"
|
||||||
>`;
|
>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set image src
|
|
||||||
*
|
|
||||||
* @param {string} _value image, app/image or url
|
|
||||||
*/
|
|
||||||
set src(_value : string)
|
|
||||||
{
|
|
||||||
this.__src = _value;
|
|
||||||
|
|
||||||
|
protected parse_href(img_href : string) : string
|
||||||
|
{
|
||||||
// allow url's too
|
// allow url's too
|
||||||
if(_value[0] == '/' || _value.substr(0, 4) == 'http' || _value.substr(0, 5) == 'data:')
|
if(img_href[0] == '/' || img_href.substr(0, 4) == 'http' || img_href.substr(0, 5) == 'data:')
|
||||||
{
|
{
|
||||||
this.setAttribute('src', _value);
|
return img_href;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
let src = this.egw().image(_value);
|
let src = this.egw()?.image(img_href);
|
||||||
if(src)
|
if(src)
|
||||||
{
|
{
|
||||||
this.setAttribute('src', src);
|
return src;
|
||||||
}
|
}
|
||||||
}
|
return "";
|
||||||
|
|
||||||
get src()
|
|
||||||
{
|
|
||||||
return this.__src;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleClick(_ev : MouseEvent) : boolean
|
_handleClick(_ev : MouseEvent) : boolean
|
||||||
@ -163,25 +164,17 @@ export class Et2Image extends Et2Widget(LitElement) implements et2_IDetachedDOM
|
|||||||
*/
|
*/
|
||||||
getDetachedAttributes(_attrs)
|
getDetachedAttributes(_attrs)
|
||||||
{
|
{
|
||||||
_attrs.push('data');
|
_attrs.push("src", "label", "href");
|
||||||
}
|
}
|
||||||
|
|
||||||
getDetachedNodes()
|
getDetachedNodes()
|
||||||
{
|
{
|
||||||
return [this.getDOMNode()];
|
return [<HTMLElement><unknown>this];
|
||||||
}
|
}
|
||||||
|
|
||||||
setDetachedAttributes(_nodes, _values)
|
setDetachedAttributes(_nodes, _values)
|
||||||
{
|
{
|
||||||
if(_values.data)
|
// Do nothing, setting attribute / property just sets it
|
||||||
{
|
|
||||||
var pairs = _values.data.split(/,/g);
|
|
||||||
for(var i = 0; i < pairs.length; ++i)
|
|
||||||
{
|
|
||||||
var name_value = pairs[i].split(':');
|
|
||||||
jQuery(_nodes[0]).attr('data-' + name_value[0], name_value[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user