mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 12:26:35 +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) {
|
set hass(hass) {
|
||||||
this._hass = hass;
|
this._hass = hass;
|
||||||
if (this.shadowRoot) {
|
this.shadowRoot!.querySelectorAll("#states > *").forEach(
|
||||||
this.shadowRoot
|
(element: unknown) => {
|
||||||
.querySelectorAll("#states > *")
|
(element as EntityRow).hass = hass;
|
||||||
.forEach((element: unknown) => {
|
}
|
||||||
(element as EntityRow).hass = hass;
|
);
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static get properties(): PropertyDeclarations {
|
static get properties(): PropertyDeclarations {
|
||||||
@ -159,14 +157,12 @@ class HuiEntitiesCard extends HassLocalizeLitMixin(LitElement)
|
|||||||
private renderEntity(entityConf) {
|
private renderEntity(entityConf) {
|
||||||
const element = createRowElement(entityConf);
|
const element = createRowElement(entityConf);
|
||||||
element.hass = this._hass;
|
element.hass = this._hass;
|
||||||
element.entityConf = entityConf;
|
|
||||||
if (
|
if (
|
||||||
entityConf.entity &&
|
entityConf.entity &&
|
||||||
!DOMAINS_HIDE_MORE_INFO.includes(computeDomain(entityConf.entity))
|
!DOMAINS_HIDE_MORE_INFO.includes(computeDomain(entityConf.entity))
|
||||||
) {
|
) {
|
||||||
element.classList.add("state-card-dialog");
|
element.classList.add("state-card-dialog");
|
||||||
// element.onclick = this.handleClick;
|
element.addEventListener("click", () => this._handleClick(entityConf));
|
||||||
element.addEventListener("click", this.handleClick);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
@ -174,9 +170,8 @@ class HuiEntitiesCard extends HassLocalizeLitMixin(LitElement)
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleClick(ev: MouseEvent) {
|
private _handleClick(entityConf: ConfigEntity) {
|
||||||
const config = (ev.currentTarget as any).entityConf as ConfigEntity;
|
const entityId = entityConf.entity;
|
||||||
const entityId = config.entity;
|
|
||||||
|
|
||||||
fireEvent(this, "hass-more-info", { entityId });
|
fireEvent(this, "hass-more-info", { entityId });
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,24 @@ export interface EntityConfig {
|
|||||||
name: string;
|
name: string;
|
||||||
icon: 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 {
|
export interface EntityRow {
|
||||||
hass: HomeAssistant;
|
hass: HomeAssistant;
|
||||||
config: EntityConfig;
|
setConfig(config: EntityConfig);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user