mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Add hold action to buttons (#7051)
This commit is contained in:
parent
4bb51b0120
commit
24f3db3e3f
@ -85,12 +85,7 @@ export class HuiButtonsBase extends LitElement {
|
|||||||
|
|
||||||
private _handleAction(ev: ActionHandlerEvent) {
|
private _handleAction(ev: ActionHandlerEvent) {
|
||||||
const config = (ev.currentTarget as any).config as EntitiesCardEntityConfig;
|
const config = (ev.currentTarget as any).config as EntitiesCardEntityConfig;
|
||||||
handleAction(
|
handleAction(this, this._hass!, config, ev.detail.action!);
|
||||||
this,
|
|
||||||
this._hass!,
|
|
||||||
{ tap_action: { action: "toggle" }, ...config },
|
|
||||||
ev.detail.action!
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles(): CSSResult {
|
static get styles(): CSSResult {
|
||||||
|
@ -4,6 +4,7 @@ import {
|
|||||||
LitElement,
|
LitElement,
|
||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
|
internalProperty,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { processConfigEntities } from "../common/process-config-entities";
|
import { processConfigEntities } from "../common/process-config-entities";
|
||||||
@ -21,15 +22,20 @@ export class HuiButtonsHeaderFooter extends LitElement
|
|||||||
|
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||||
|
|
||||||
private _configEntities?: EntityConfig[];
|
@internalProperty() private _configEntities?: EntityConfig[];
|
||||||
|
|
||||||
public getCardSize(): number {
|
public getCardSize(): number {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setConfig(config: ButtonsHeaderFooterConfig): void {
|
public setConfig(config: ButtonsHeaderFooterConfig): void {
|
||||||
this._configEntities = processConfigEntities(config.entities);
|
this._configEntities = processConfigEntities(config.entities).map(
|
||||||
this.requestUpdate();
|
(entityConfig) => ({
|
||||||
|
tap_action: { action: "toggle" },
|
||||||
|
hold_action: { action: "more-info" },
|
||||||
|
...entityConfig,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult | void {
|
protected render(): TemplateResult | void {
|
||||||
|
@ -4,6 +4,7 @@ import {
|
|||||||
LitElement,
|
LitElement,
|
||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
|
internalProperty,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { processConfigEntities } from "../common/process-config-entities";
|
import { processConfigEntities } from "../common/process-config-entities";
|
||||||
@ -22,11 +23,16 @@ export class HuiButtonsRow extends LitElement implements LovelaceRow {
|
|||||||
|
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||||
|
|
||||||
private _configEntities?: EntityConfig[];
|
@internalProperty() private _configEntities?: EntityConfig[];
|
||||||
|
|
||||||
public setConfig(config: ButtonsRowConfig): void {
|
public setConfig(config: ButtonsRowConfig): void {
|
||||||
this._configEntities = processConfigEntities(config.entities);
|
this._configEntities = processConfigEntities(config.entities).map(
|
||||||
this.requestUpdate();
|
(entityConfig) => ({
|
||||||
|
tap_action: { action: "toggle" },
|
||||||
|
hold_action: { action: "more-info" },
|
||||||
|
...entityConfig,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult | void {
|
protected render(): TemplateResult | void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user