mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 13:27:22 +00:00
Review updates
This commit is contained in:
parent
66f5e34d52
commit
7fbe0937df
@ -36,13 +36,11 @@ class HuiEntitiesCard extends HassLocalizeLitMixin(LitElement)
|
||||
|
||||
set hass(hass) {
|
||||
this._hass = hass;
|
||||
if (this.shadowRoot) {
|
||||
this.shadowRoot
|
||||
.querySelectorAll("#states > *")
|
||||
.forEach((element: unknown) => {
|
||||
(element as EntityRow).hass = hass;
|
||||
});
|
||||
}
|
||||
this.shadowRoot!.querySelectorAll("#states > *").forEach(
|
||||
(element: unknown) => {
|
||||
(element as EntityRow).hass = hass;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
static get properties(): PropertyDeclarations {
|
||||
@ -159,14 +157,12 @@ class HuiEntitiesCard extends HassLocalizeLitMixin(LitElement)
|
||||
private renderEntity(entityConf) {
|
||||
const element = createRowElement(entityConf);
|
||||
element.hass = this._hass;
|
||||
element.entityConf = entityConf;
|
||||
if (
|
||||
entityConf.entity &&
|
||||
!DOMAINS_HIDE_MORE_INFO.includes(computeDomain(entityConf.entity))
|
||||
) {
|
||||
element.classList.add("state-card-dialog");
|
||||
// element.onclick = this.handleClick;
|
||||
element.addEventListener("click", this.handleClick);
|
||||
element.addEventListener("click", () => this._handleClick(entityConf));
|
||||
}
|
||||
|
||||
return html`
|
||||
@ -174,9 +170,8 @@ class HuiEntitiesCard extends HassLocalizeLitMixin(LitElement)
|
||||
`;
|
||||
}
|
||||
|
||||
private handleClick(ev: MouseEvent) {
|
||||
const config = (ev.currentTarget as any).entityConf as ConfigEntity;
|
||||
const entityId = config.entity;
|
||||
private _handleClick(entityConf: ConfigEntity) {
|
||||
const entityId = entityConf.entity;
|
||||
|
||||
fireEvent(this, "hass-more-info", { entityId });
|
||||
}
|
||||
|
@ -5,8 +5,24 @@ export interface EntityConfig {
|
||||
name: string;
|
||||
icon: string;
|
||||
}
|
||||
export interface DividerConfig {
|
||||
style: string;
|
||||
}
|
||||
export interface SectionConfig {
|
||||
label: string;
|
||||
}
|
||||
export interface WeblinkConfig {
|
||||
name: string;
|
||||
icon: string;
|
||||
url: string;
|
||||
}
|
||||
export type EntityRowConfig =
|
||||
| EntityConfig
|
||||
| DividerConfig
|
||||
| SectionConfig
|
||||
| WeblinkConfig;
|
||||
|
||||
export interface EntityRow {
|
||||
hass: HomeAssistant;
|
||||
config: EntityConfig;
|
||||
setConfig(config: EntityConfig);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user