Always show description field in automation editor (#13503)

This commit is contained in:
Franck Nijhof 2022-08-26 15:25:01 +02:00 committed by GitHub
parent 35fa763086
commit 2547a975f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,8 @@
import "@material/mwc-button/mwc-button"; import "@material/mwc-button/mwc-button";
import { mdiHelpCircle, mdiRobot } from "@mdi/js"; import { mdiHelpCircle, mdiRobot } from "@mdi/js";
import { HassEntity } from "home-assistant-js-websocket"; import { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit"; import { css, CSSResultGroup, html, LitElement } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property } 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";
@ -35,20 +35,16 @@ export class HaManualAutomationEditor extends LitElement {
@property({ attribute: false }) public stateObj?: HassEntity; @property({ attribute: false }) public stateObj?: HassEntity;
@state() private _showDescription = false;
protected render() { protected render() {
return html` return html`
<ha-card outlined> <ha-card outlined>
${ ${this.stateObj && this.stateObj.state === "off"
this.stateObj && this.stateObj.state === "off"
? html`<div class="disabled-bar"> ? html`<div class="disabled-bar">
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.automation.editor.disabled" "ui.panel.config.automation.editor.disabled"
)} )}
</div>` </div>`
: "" : ""}
}
<ha-expansion-panel leftChevron> <ha-expansion-panel leftChevron>
<div slot="header"> <div slot="header">
@ -58,10 +54,6 @@ export class HaManualAutomationEditor extends LitElement {
)} )}
</div> </div>
<div class="card-content"> <div class="card-content">
</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"
@ -74,17 +66,6 @@ export class HaManualAutomationEditor extends LitElement {
.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>
`
}
<ha-select <ha-select
.label=${this.hass.localize( .label=${this.hass.localize(
"ui.panel.config.automation.editor.modes.label" "ui.panel.config.automation.editor.modes.label"
@ -114,8 +95,7 @@ export class HaManualAutomationEditor extends LitElement {
` `
)} )}
</ha-select> </ha-select>
${ ${this.config.mode && isMaxMode(this.config.mode)
this.config.mode && isMaxMode(this.config.mode)
? html` ? html`
<br /><ha-textfield <br /><ha-textfield
.label=${this.hass.localize( .label=${this.hass.localize(
@ -129,8 +109,7 @@ export class HaManualAutomationEditor extends LitElement {
> >
</ha-textfield> </ha-textfield>
` `
: html`` : html``}
}
</div> </div>
</ha-expansion-panel> </ha-expansion-panel>
</ha-card> </ha-card>
@ -216,17 +195,6 @@ export class HaManualAutomationEditor extends LitElement {
`; `;
} }
protected willUpdate(changedProps: PropertyValues): void {
super.willUpdate(changedProps);
if (
!this._showDescription &&
changedProps.has("config") &&
this.config.description
) {
this._showDescription = true;
}
}
private _valueChanged(ev: CustomEvent) { private _valueChanged(ev: CustomEvent) {
ev.stopPropagation(); ev.stopPropagation();
const target = ev.target as any; const target = ev.target as any;
@ -293,10 +261,6 @@ export class HaManualAutomationEditor extends LitElement {
}); });
} }
private _addDescription() {
this._showDescription = true;
}
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {
return [ return [
haStyle, haStyle,
@ -346,6 +310,9 @@ export class HaManualAutomationEditor extends LitElement {
.card-content { .card-content {
padding: 16px; padding: 16px;
} }
.card-content ha-textarea:first-child {
margin-top: -16px;
}
.settings-icon { .settings-icon {
display: none; display: none;
} }