From ccebae84a7d2b6d3feecf54d6fc7a4d44e182ca8 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 28 May 2024 18:23:12 +0200 Subject: [PATCH] Use list for change mode dialog (#20890) * Use list for change mode dialog * Add listbox role * Remove unused import --- .../dialog-automation-mode.ts | 152 ++++++++++++------ src/translations/en.json | 6 +- 2 files changed, 108 insertions(+), 50 deletions(-) diff --git a/src/panels/config/automation/automation-mode-dialog/dialog-automation-mode.ts b/src/panels/config/automation/automation-mode-dialog/dialog-automation-mode.ts index ba624d0721..d13a36124e 100644 --- a/src/panels/config/automation/automation-mode-dialog/dialog-automation-mode.ts +++ b/src/panels/config/automation/automation-mode-dialog/dialog-automation-mode.ts @@ -1,17 +1,21 @@ import "@material/mwc-button"; import "@material/mwc-list/mwc-list-item"; -import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; +import { mdiClose, mdiHelpCircle } from "@mdi/js"; +import { CSSResultGroup, LitElement, css, html, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; -import { stopPropagation } from "../../../../common/dom/stop_propagation"; -import { createCloseHeading } from "../../../../components/ha-dialog"; -import "../../../../components/ha-select"; +import "../../../../components/ha-dialog-header"; +import "../../../../components/ha-icon-button"; +import "../../../../components/ha-list-item-new"; +import "../../../../components/ha-list-new"; +import "../../../../components/ha-radio"; import "../../../../components/ha-textfield"; + import { AUTOMATION_DEFAULT_MAX, AUTOMATION_DEFAULT_MODE, } from "../../../../data/automation"; -import { isMaxMode, MODES } from "../../../../data/script"; +import { MODES, isMaxMode } from "../../../../data/script"; import { HassDialog } from "../../../../dialogs/make-dialog-manager"; import { haStyle, haStyleDialog } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; @@ -53,59 +57,101 @@ class DialogAutomationMode extends LitElement implements HassDialog { return nothing; } + const title = this.hass.localize( + "ui.panel.config.automation.editor.change_mode" + ); + return html` - + +
${title}
+ + + + + ${this.hass.localize( - "ui.panel.config.automation.editor.modes.learn_more" - )} - `} > - ${MODES.map( - (mode) => html` - - ${this.hass.localize( - `ui.panel.config.automation.editor.modes.${mode}` - ) || mode} - - ` - )} -
+ ${MODES.map((mode) => { + const label = this.hass.localize( + `ui.panel.config.automation.editor.modes.${mode}` + ); + return html` + +
+ +
+
+ ${this.hass.localize( + `ui.panel.config.automation.editor.modes.${mode}` + )} +
+
+ ${this.hass.localize( + `ui.panel.config.automation.editor.modes.${mode}_description` + )} +
+
+ `; + })} + + ${isMaxMode(this._newMode) ? html` -
- +
+ + +
` : nothing} @@ -120,7 +166,7 @@ class DialogAutomationMode extends LitElement implements HassDialog { } private _modeChanged(ev) { - const mode = ev.target.value; + const mode = ev.currentTarget.value; this._newMode = mode; if (!isMaxMode(mode)) { this._newMax = undefined; @@ -151,10 +197,18 @@ class DialogAutomationMode extends LitElement implements HassDialog { haStyle, haStyleDialog, css` - ha-select, ha-textfield { display: block; } + ha-dialog { + --dialog-content-padding: 0; + } + .options { + padding: 0 24px 24px 24px; + } + ha-dialog-header a { + color: inherit; + } `, ]; } diff --git a/src/translations/en.json b/src/translations/en.json index 4aca6a8a5e..17437325a6 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2777,9 +2777,13 @@ "label": "Mode", "learn_more": "Learn about modes", "single": "Single", + "single_description": "Do not start a new run. Issue a warning.", "restart": "Restart", + "restart_description": "Start a new run after first stopping the previous run.", "queued": "Queued", - "parallel": "Parallel" + "queued_description": "Start a new run after all previous runs complete.", + "parallel": "Parallel", + "parallel_description": "Start a new, independent run in parallel with previous runs." }, "max": { "queued": "Queue length",