Resolve some Et2ButtonIcon issues from Shoelace upgrade

- Avoid some 404s with egroupware icons trying to load from shoelace
- Fix Shoelace icon not shown when button has an ID
This commit is contained in:
nathan 2024-03-13 09:16:46 -06:00
parent 0846fa78f3
commit 7ed9eef29d
2 changed files with 16 additions and 5 deletions

View File

@ -43,11 +43,22 @@ export class Et2ButtonIcon extends ButtonMixin(Et2InputWidget(SlIconButton))
{
this.src = this.egw().image(new_image);
}
if(new_image && !this.src)
// For some reason setting it directly does not show the image
this.updateComplete.then(() =>
{
// For some reason setting it directly does not show the image
this.updateComplete.then(() => this.name = new_image);
}
const icon = this.shadowRoot.querySelector('sl-icon');
icon.id = "";
if(new_image && !this.src)
{
icon.src = "";
icon.name = new_image;
}
else
{
icon.name = "";
}
});
}
get image()

View File

@ -15,7 +15,7 @@ import {egw} from "../../jsapi/egw_global";
registerIconLibrary('default', {
resolver: name =>
{
return typeof egw !== "undefined" ? `${egw.webserverUrl || ""}/node_modules/@shoelace-style/shoelace/dist/assets/icons/${name}.svg` : ''
return typeof egw !== "undefined" ? (egw.image(name) ?? `${egw.webserverUrl || ""}/node_modules/@shoelace-style/shoelace/dist/assets/icons/${name}.svg`) : ''
},
});