From 94f679e387ef3ec9e4a3878389ebd5a7803e328b Mon Sep 17 00:00:00 2001 From: Jan-Philipp Benecke Date: Tue, 24 Dec 2024 11:21:03 +0100 Subject: [PATCH] Add area to automation/script save dialog (#23416) Add area chip to automation/script save dialog --- .../dialog-automation-rename.ts | 19 +++++++++++++++++++ .../show-dialog-automation-rename.ts | 1 + .../config/automation/ha-automation-editor.ts | 1 + src/panels/config/script/ha-script-editor.ts | 1 + src/translations/en.json | 3 ++- 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/panels/config/automation/automation-rename-dialog/dialog-automation-rename.ts b/src/panels/config/automation/automation-rename-dialog/dialog-automation-rename.ts index cf429a3187..df0b7aa1d0 100644 --- a/src/panels/config/automation/automation-rename-dialog/dialog-automation-rename.ts +++ b/src/panels/config/automation/automation-rename-dialog/dialog-automation-rename.ts @@ -14,6 +14,7 @@ import "../../category/ha-category-picker"; import "../../../../components/ha-expansion-panel"; import "../../../../components/chips/ha-chip-set"; import "../../../../components/chips/ha-assist-chip"; +import "../../../../components/ha-area-picker"; import type { HassDialog } from "../../../../dialogs/make-dialog-manager"; import { haStyle, haStyleDialog } from "../../../../resources/styles"; @@ -57,6 +58,7 @@ class DialogAutomationRename extends LitElement implements HassDialog { ); this._newDescription = params.config.description || ""; this._entryUpdates = params.entityRegistryUpdate || { + area: params.entityRegistryEntry?.area_id || "", labels: params.entityRegistryEntry?.labels || [], category: params.entityRegistryEntry?.categories[params.domain] || "", }; @@ -66,6 +68,7 @@ class DialogAutomationRename extends LitElement implements HassDialog { this._newIcon ? "icon" : "", this._entryUpdates.category ? "category" : "", this._entryUpdates.labels.length > 0 ? "labels" : "", + this._entryUpdates.area ? "area" : "", ]; } @@ -193,6 +196,14 @@ class DialogAutomationRename extends LitElement implements HassDialog { @value-changed=${this._registryEntryChanged} >` : nothing} + ${this._visibleOptionals.includes("area") + ? html` ` + : nothing} ${this._renderOptionalChip( @@ -209,6 +220,12 @@ class DialogAutomationRename extends LitElement implements HassDialog { ) ) : nothing} + ${this._renderOptionalChip( + "area", + this.hass.localize( + "ui.panel.config.automation.editor.dialog.add_area" + ) + )} ${this._renderOptionalChip( "category", this.hass.localize( @@ -311,12 +328,14 @@ class DialogAutomationRename extends LitElement implements HassDialog { ha-icon-picker, ha-category-picker, ha-labels-picker, + ha-area-picker, ha-chip-set { display: block; } ha-icon-picker, ha-category-picker, ha-labels-picker, + ha-area-picker, ha-chip-set { margin-top: 16px; } diff --git a/src/panels/config/automation/automation-rename-dialog/show-dialog-automation-rename.ts b/src/panels/config/automation/automation-rename-dialog/show-dialog-automation-rename.ts index 7ee809c3c0..4573fc85f2 100644 --- a/src/panels/config/automation/automation-rename-dialog/show-dialog-automation-rename.ts +++ b/src/panels/config/automation/automation-rename-dialog/show-dialog-automation-rename.ts @@ -13,6 +13,7 @@ interface BaseRenameDialogParams { } export interface EntityRegistryUpdate { + area: string; labels: string[]; category: string; } diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index fb5d363680..07939ecdf6 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -950,6 +950,7 @@ export class HaAutomationEditor extends PreventUnsavedMixin( automation: this._entityRegistryUpdate.category || null, }, labels: this._entityRegistryUpdate.labels || [], + area_id: this._entityRegistryUpdate.area || null, }); } } diff --git a/src/panels/config/script/ha-script-editor.ts b/src/panels/config/script/ha-script-editor.ts index c75f8c151a..8c1d65e8ea 100644 --- a/src/panels/config/script/ha-script-editor.ts +++ b/src/panels/config/script/ha-script-editor.ts @@ -919,6 +919,7 @@ export class HaScriptEditor extends SubscribeMixin( script: this._entityRegistryUpdate.category || null, }, labels: this._entityRegistryUpdate.labels || [], + area_id: this._entityRegistryUpdate.area || null, }); } diff --git a/src/translations/en.json b/src/translations/en.json index 5efb80aa9b..0b1477cba9 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -3718,7 +3718,8 @@ "add_description": "Add description", "add_icon": "Add icon", "add_category": "Add category", - "add_labels": "Add labels" + "add_labels": "Add labels", + "add_area": "Add area" } }, "trace": {