mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-12 03:46:34 +00:00
Only show description when set (#11772)
This commit is contained in:
parent
b1f369a355
commit
d230541256
@ -1,7 +1,7 @@
|
|||||||
import "@material/mwc-button/mwc-button";
|
import "@material/mwc-button/mwc-button";
|
||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { css, CSSResultGroup, html, LitElement } from "lit";
|
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import "../../../components/entity/ha-entity-toggle";
|
import "../../../components/entity/ha-entity-toggle";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
@ -34,6 +34,8 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
|
|
||||||
@property() public stateObj?: HassEntity;
|
@property() public stateObj?: HassEntity;
|
||||||
|
|
||||||
|
@state() private _showDescription = false;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`<ha-config-section vertical .isWide=${this.isWide}>
|
return html`<ha-config-section vertical .isWide=${this.isWide}>
|
||||||
${!this.narrow
|
${!this.narrow
|
||||||
@ -55,6 +57,8 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
@change=${this._valueChanged}
|
@change=${this._valueChanged}
|
||||||
>
|
>
|
||||||
</ha-textfield>
|
</ha-textfield>
|
||||||
|
${this._showDescription
|
||||||
|
? html`
|
||||||
<ha-textarea
|
<ha-textarea
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.description.label"
|
"ui.panel.config.automation.editor.description.label"
|
||||||
@ -63,9 +67,20 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
"ui.panel.config.automation.editor.description.placeholder"
|
"ui.panel.config.automation.editor.description.placeholder"
|
||||||
)}
|
)}
|
||||||
name="description"
|
name="description"
|
||||||
|
autogrow
|
||||||
.value=${this.config.description || ""}
|
.value=${this.config.description || ""}
|
||||||
@change=${this._valueChanged}
|
@change=${this._valueChanged}
|
||||||
></ha-textarea>
|
></ha-textarea>
|
||||||
|
`
|
||||||
|
: html`
|
||||||
|
<div class="link-button-row">
|
||||||
|
<button class="link" @click=${this._addDescription}>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.description.add"
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`}
|
||||||
<p>
|
<p>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.modes.description",
|
"ui.panel.config.automation.editor.modes.description",
|
||||||
@ -235,6 +250,17 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
</ha-config-section>`;
|
</ha-config-section>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected willUpdate(changedProps: PropertyValues): void {
|
||||||
|
super.willUpdate(changedProps);
|
||||||
|
if (
|
||||||
|
!this._showDescription &&
|
||||||
|
changedProps.has("config") &&
|
||||||
|
this.config.description
|
||||||
|
) {
|
||||||
|
this._showDescription = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _runActions(ev: Event) {
|
private _runActions(ev: Event) {
|
||||||
triggerAutomationActions(this.hass, (ev.target as any).stateObj.entity_id);
|
triggerAutomationActions(this.hass, (ev.target as any).stateObj.entity_id);
|
||||||
}
|
}
|
||||||
@ -305,6 +331,10 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _addDescription() {
|
||||||
|
this._showDescription = true;
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
haStyle,
|
haStyle,
|
||||||
@ -312,6 +342,12 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
ha-card {
|
ha-card {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
.link-button-row {
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
ha-textarea {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
span[slot="introduction"] a {
|
span[slot="introduction"] a {
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
}
|
}
|
||||||
|
@ -1593,7 +1593,8 @@
|
|||||||
"move_down": "Move down",
|
"move_down": "Move down",
|
||||||
"description": {
|
"description": {
|
||||||
"label": "Description",
|
"label": "Description",
|
||||||
"placeholder": "Optional description"
|
"placeholder": "Optional description",
|
||||||
|
"add": "Add description"
|
||||||
},
|
},
|
||||||
"blueprint": {
|
"blueprint": {
|
||||||
"header": "Blueprint",
|
"header": "Blueprint",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user