mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +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 { css, html, LitElement } from "lit";
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import "../../../../../components/ha-textarea";
|
||||
import type { TemplateCondition } from "../../../../../data/automation";
|
||||
import type { HomeAssistant } from "../../../../../types";
|
||||
import { handleChangeEvent } from "../ha-automation-condition-row";
|
||||
@ -18,28 +18,27 @@ export class HaTemplateCondition extends LitElement {
|
||||
protected render() {
|
||||
const { value_template } = this.condition;
|
||||
return html`
|
||||
<ha-textarea
|
||||
name="value_template"
|
||||
.label=${this.hass.localize(
|
||||
<p>
|
||||
${this.hass.localize(
|
||||
"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}
|
||||
@input=${this._valueChanged}
|
||||
autocomplete-entities
|
||||
@value-changed=${this._valueChanged}
|
||||
dir="ltr"
|
||||
autogrow
|
||||
></ha-textarea>
|
||||
></ha-code-editor>
|
||||
`;
|
||||
}
|
||||
|
||||
private _valueChanged(ev: CustomEvent): void {
|
||||
handleChangeEvent(this, ev);
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
ha-textarea {
|
||||
display: block;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import "../../../../../components/ha-textarea";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import type { TemplateTrigger } from "../../../../../data/automation";
|
||||
import type { HomeAssistant } from "../../../../../types";
|
||||
@ -18,28 +18,27 @@ export class HaTemplateTrigger extends LitElement {
|
||||
protected render() {
|
||||
const { value_template } = this.trigger;
|
||||
return html`
|
||||
<ha-textarea
|
||||
name="value_template"
|
||||
.label=${this.hass.localize(
|
||||
<p>
|
||||
${this.hass.localize(
|
||||
"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}
|
||||
@input=${this._valueChanged}
|
||||
autocomplete-entities
|
||||
@value-changed=${this._valueChanged}
|
||||
dir="ltr"
|
||||
autogrow
|
||||
></ha-textarea>
|
||||
></ha-code-editor>
|
||||
`;
|
||||
}
|
||||
|
||||
private _valueChanged(ev: CustomEvent): void {
|
||||
handleChangeEvent(this, ev);
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
ha-textarea {
|
||||
display: block;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
Loading…
x
Reference in New Issue
Block a user