mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Add jinja2 editor to template triggers/conditions (#12365)
Co-authored-by: Zack <zackbarett@hey.com>
This commit is contained in:
parent
2099259393
commit
6865791596
@ -1,6 +1,6 @@
|
|||||||
import "../../../../../components/ha-textarea";
|
import { html, LitElement } from "lit";
|
||||||
import { css, html, LitElement } from "lit";
|
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import "../../../../../components/ha-textarea";
|
||||||
import type { TemplateCondition } from "../../../../../data/automation";
|
import type { TemplateCondition } from "../../../../../data/automation";
|
||||||
import type { HomeAssistant } from "../../../../../types";
|
import type { HomeAssistant } from "../../../../../types";
|
||||||
import { handleChangeEvent } from "../ha-automation-condition-row";
|
import { handleChangeEvent } from "../ha-automation-condition-row";
|
||||||
@ -18,28 +18,27 @@ export class HaTemplateCondition extends LitElement {
|
|||||||
protected render() {
|
protected render() {
|
||||||
const { value_template } = this.condition;
|
const { value_template } = this.condition;
|
||||||
return html`
|
return html`
|
||||||
<ha-textarea
|
<p>
|
||||||
name="value_template"
|
${this.hass.localize(
|
||||||
.label=${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.conditions.type.template.value_template"
|
"ui.panel.config.automation.editor.conditions.type.template.value_template"
|
||||||
)}
|
)}
|
||||||
|
*
|
||||||
|
</p>
|
||||||
|
<ha-code-editor
|
||||||
|
.name=${"value_template"}
|
||||||
|
mode="jinja2"
|
||||||
|
.hass=${this.hass}
|
||||||
.value=${value_template}
|
.value=${value_template}
|
||||||
@input=${this._valueChanged}
|
autocomplete-entities
|
||||||
|
@value-changed=${this._valueChanged}
|
||||||
dir="ltr"
|
dir="ltr"
|
||||||
autogrow
|
></ha-code-editor>
|
||||||
></ha-textarea>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _valueChanged(ev: CustomEvent): void {
|
private _valueChanged(ev: CustomEvent): void {
|
||||||
handleChangeEvent(this, ev);
|
handleChangeEvent(this, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = css`
|
|
||||||
ha-textarea {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import "../../../../../components/ha-textarea";
|
import "../../../../../components/ha-textarea";
|
||||||
import { css, html, LitElement } from "lit";
|
import { html, LitElement } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import type { TemplateTrigger } from "../../../../../data/automation";
|
import type { TemplateTrigger } from "../../../../../data/automation";
|
||||||
import type { HomeAssistant } from "../../../../../types";
|
import type { HomeAssistant } from "../../../../../types";
|
||||||
@ -18,28 +18,27 @@ export class HaTemplateTrigger extends LitElement {
|
|||||||
protected render() {
|
protected render() {
|
||||||
const { value_template } = this.trigger;
|
const { value_template } = this.trigger;
|
||||||
return html`
|
return html`
|
||||||
<ha-textarea
|
<p>
|
||||||
name="value_template"
|
${this.hass.localize(
|
||||||
.label=${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.triggers.type.template.value_template"
|
"ui.panel.config.automation.editor.triggers.type.template.value_template"
|
||||||
)}
|
)}
|
||||||
|
*
|
||||||
|
</p>
|
||||||
|
<ha-code-editor
|
||||||
|
.name=${"value_template"}
|
||||||
|
mode="jinja2"
|
||||||
|
.hass=${this.hass}
|
||||||
.value=${value_template}
|
.value=${value_template}
|
||||||
@input=${this._valueChanged}
|
autocomplete-entities
|
||||||
|
@value-changed=${this._valueChanged}
|
||||||
dir="ltr"
|
dir="ltr"
|
||||||
autogrow
|
></ha-code-editor>
|
||||||
></ha-textarea>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _valueChanged(ev: CustomEvent): void {
|
private _valueChanged(ev: CustomEvent): void {
|
||||||
handleChangeEvent(this, ev);
|
handleChangeEvent(this, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = css`
|
|
||||||
ha-textarea {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user