Add collapse/expand all for automations (#26695)

This commit is contained in:
Wendelin
2025-08-26 15:21:03 +02:00
committed by GitHub
parent 1fe7282b0e
commit 5709cb6aa4
27 changed files with 537 additions and 42 deletions

View File

@@ -1,7 +1,7 @@
import { mdiPlus } from "@mdi/js";
import type { PropertyValues } from "lit";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { customElement, property, queryAll } from "lit/decorators";
import { fireEvent } from "../../../common/dom/fire_event";
import "../../../components/ha-button";
import "../../../components/ha-button-menu";
@@ -23,6 +23,9 @@ export default class HaScriptFields extends LitElement {
@property({ type: Boolean }) public narrow = false;
@queryAll("ha-script-field-row")
private _fieldRowElements?: HaScriptFieldRow[];
private _focusLastActionOnChange = false;
protected render() {
@@ -48,12 +51,7 @@ export default class HaScriptFields extends LitElement {
)}
</div> `
: nothing}
<ha-button
appearance="filled"
size="small"
@click=${this._addField}
.disabled=${this.disabled}
>
<ha-button @click=${this._addField} .disabled=${this.disabled}>
<ha-svg-icon .path=${mdiPlus} slot="start"></ha-svg-icon>
${this.hass.localize("ui.panel.config.script.editor.field.add_field")}
</ha-button>
@@ -144,6 +142,18 @@ export default class HaScriptFields extends LitElement {
return key;
}
public expandAll() {
this._fieldRowElements?.forEach((row) => {
row.expandAll();
});
}
public collapseAll() {
this._fieldRowElements?.forEach((row) => {
row.collapseAll();
});
}
static styles = css`
ha-script-field-row {
display: block;