mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Fix for unavailable input-select (#4991)
* Fix for unavailable select * Update hui-thermostat-card.ts
This commit is contained in:
parent
5646045e9e
commit
0d6de9fe73
@ -190,6 +190,10 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#states > div {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
padding: 0px 18px 0px 8px;
|
padding: 0px 18px 0px 8px;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import { toggleEntity } from "../common/entity/toggle-entity";
|
|||||||
import { LightCardConfig } from "./types";
|
import { LightCardConfig } from "./types";
|
||||||
import { supportsFeature } from "../../../common/entity/supports-feature";
|
import { supportsFeature } from "../../../common/entity/supports-feature";
|
||||||
import { SUPPORT_BRIGHTNESS } from "../../../data/light";
|
import { SUPPORT_BRIGHTNESS } from "../../../data/light";
|
||||||
|
import { UNAVAILABLE } from "../../../data/entity";
|
||||||
|
|
||||||
@customElement("hui-light-card")
|
@customElement("hui-light-card")
|
||||||
export class HuiLightCard extends LitElement implements LovelaceCard {
|
export class HuiLightCard extends LitElement implements LovelaceCard {
|
||||||
@ -84,10 +85,11 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-card>
|
<ha-card>
|
||||||
${stateObj.state === "unavailable"
|
${stateObj.state === UNAVAILABLE
|
||||||
? html`
|
? html`
|
||||||
<hui-unavailable
|
<hui-unavailable
|
||||||
.text="${this.hass.localize("state.default.unavailable")}"
|
.text=${this.hass.localize("state.default.unavailable")}
|
||||||
|
@click=${this._handleMoreInfo}
|
||||||
></hui-unavailable>
|
></hui-unavailable>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
@ -233,6 +235,10 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hui-unavailable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
ha-card {
|
ha-card {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -34,6 +34,7 @@ import {
|
|||||||
} from "../../../data/climate";
|
} from "../../../data/climate";
|
||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||||
|
import { UNAVAILABLE } from "../../../data/entity";
|
||||||
|
|
||||||
const modeIcons: { [mode in HvacMode]: string } = {
|
const modeIcons: { [mode in HvacMode]: string } = {
|
||||||
auto: "hass:calendar-repeat",
|
auto: "hass:calendar-repeat",
|
||||||
@ -208,10 +209,11 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
|
|||||||
[mode]: true,
|
[mode]: true,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
${stateObj.state === "unavailable"
|
${stateObj.state === UNAVAILABLE
|
||||||
? html`
|
? html`
|
||||||
<hui-unavailable
|
<hui-unavailable
|
||||||
.text="${this.hass.localize("state.default.unavailable")}"
|
.text="${this.hass.localize("state.default.unavailable")}"
|
||||||
|
@click=${this._handleMoreInfo}
|
||||||
></hui-unavailable>
|
></hui-unavailable>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
@ -396,6 +398,10 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hui-unavailable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
ha-card {
|
ha-card {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -32,6 +32,8 @@ import { actionHandler } from "../common/directives/action-handler-directive";
|
|||||||
import { hasAction } from "../common/has-action";
|
import { hasAction } from "../common/has-action";
|
||||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||||
import { handleAction } from "../common/handle-action";
|
import { handleAction } from "../common/handle-action";
|
||||||
|
import { UNAVAILABLE } from "../../../data/entity";
|
||||||
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
|
|
||||||
@customElement("hui-input-select-entity-row")
|
@customElement("hui-input-select-entity-row")
|
||||||
class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
||||||
@ -78,6 +80,14 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
!DOMAINS_HIDE_MORE_INFO.includes(computeDomain(this._config.entity)));
|
!DOMAINS_HIDE_MORE_INFO.includes(computeDomain(this._config.entity)));
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
${stateObj.state === UNAVAILABLE
|
||||||
|
? html`
|
||||||
|
<hui-unavailable
|
||||||
|
.text=${this.hass.localize("state.default.unavailable")}
|
||||||
|
@click=${this._showMoreInfo}
|
||||||
|
></hui-unavailable>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
<state-badge
|
<state-badge
|
||||||
.stateObj=${stateObj}
|
.stateObj=${stateObj}
|
||||||
.stateColor=${this._config.state_color}
|
.stateColor=${this._config.state_color}
|
||||||
@ -100,11 +110,13 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
@click=${stopPropagation}
|
@click=${stopPropagation}
|
||||||
>
|
>
|
||||||
<paper-listbox slot="dropdown-content">
|
<paper-listbox slot="dropdown-content">
|
||||||
${stateObj.attributes.options.map(
|
${stateObj.attributes.options
|
||||||
(option) => html`
|
? stateObj.attributes.options.map(
|
||||||
<paper-item>${option}</paper-item>
|
(option) => html`
|
||||||
`
|
<paper-item>${option}</paper-item>
|
||||||
)}
|
`
|
||||||
|
)
|
||||||
|
: ""}
|
||||||
</paper-listbox>
|
</paper-listbox>
|
||||||
</ha-paper-dropdown-menu>
|
</ha-paper-dropdown-menu>
|
||||||
`;
|
`;
|
||||||
@ -126,15 +138,21 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update selected after rendering the items or else it won't work in Firefox
|
// Update selected after rendering the items or else it won't work in Firefox
|
||||||
this.shadowRoot!.querySelector(
|
if (stateObj.attributes.options) {
|
||||||
"paper-listbox"
|
this.shadowRoot!.querySelector(
|
||||||
)!.selected = stateObj.attributes.options.indexOf(stateObj.state);
|
"paper-listbox"
|
||||||
|
)!.selected = stateObj.attributes.options.indexOf(stateObj.state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleAction(ev: ActionHandlerEvent) {
|
private _handleAction(ev: ActionHandlerEvent) {
|
||||||
handleAction(this, this.hass!, this._config!, ev.detail.action!);
|
handleAction(this, this.hass!, this._config!, ev.detail.action!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _showMoreInfo() {
|
||||||
|
fireEvent(this, "hass-more-info", { entityId: this._config!.entity });
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResult {
|
static get styles(): CSSResult {
|
||||||
return css`
|
return css`
|
||||||
:host {
|
:host {
|
||||||
@ -157,6 +175,9 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
background: var(--divider-color);
|
background: var(--divider-color);
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
}
|
}
|
||||||
|
hui-unavailable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user