mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +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) {
|
||||
const config = (ev.currentTarget as any).config as EntitiesCardEntityConfig;
|
||||
handleAction(
|
||||
this,
|
||||
this._hass!,
|
||||
{ tap_action: { action: "toggle" }, ...config },
|
||||
ev.detail.action!
|
||||
);
|
||||
handleAction(this, this._hass!, config, ev.detail.action!);
|
||||
}
|
||||
|
||||
static get styles(): CSSResult {
|
||||
|
@ -4,6 +4,7 @@ import {
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
internalProperty,
|
||||
} from "lit-element";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { processConfigEntities } from "../common/process-config-entities";
|
||||
@ -21,15 +22,20 @@ export class HuiButtonsHeaderFooter extends LitElement
|
||||
|
||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||
|
||||
private _configEntities?: EntityConfig[];
|
||||
@internalProperty() private _configEntities?: EntityConfig[];
|
||||
|
||||
public getCardSize(): number {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public setConfig(config: ButtonsHeaderFooterConfig): void {
|
||||
this._configEntities = processConfigEntities(config.entities);
|
||||
this.requestUpdate();
|
||||
this._configEntities = processConfigEntities(config.entities).map(
|
||||
(entityConfig) => ({
|
||||
tap_action: { action: "toggle" },
|
||||
hold_action: { action: "more-info" },
|
||||
...entityConfig,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
protected render(): TemplateResult | void {
|
||||
|
@ -4,6 +4,7 @@ import {
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
internalProperty,
|
||||
} from "lit-element";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { processConfigEntities } from "../common/process-config-entities";
|
||||
@ -22,11 +23,16 @@ export class HuiButtonsRow extends LitElement implements LovelaceRow {
|
||||
|
||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||
|
||||
private _configEntities?: EntityConfig[];
|
||||
@internalProperty() private _configEntities?: EntityConfig[];
|
||||
|
||||
public setConfig(config: ButtonsRowConfig): void {
|
||||
this._configEntities = processConfigEntities(config.entities);
|
||||
this.requestUpdate();
|
||||
this._configEntities = processConfigEntities(config.entities).map(
|
||||
(entityConfig) => ({
|
||||
tap_action: { action: "toggle" },
|
||||
hold_action: { action: "more-info" },
|
||||
...entityConfig,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
protected render(): TemplateResult | void {
|
||||
|
Loading…
x
Reference in New Issue
Block a user