Add area to automation/script save dialog (#23416)

Add area chip to automation/script save dialog
This commit is contained in:
Jan-Philipp Benecke 2024-12-24 11:21:03 +01:00 committed by GitHub
parent 85bd6432a9
commit 94f679e387
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 1 deletions

View File

@ -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}
></ha-labels-picker>`
: nothing}
${this._visibleOptionals.includes("area")
? html` <ha-area-picker
id="area"
.hass=${this.hass}
.value=${this._entryUpdates.area}
@value-changed=${this._registryEntryChanged}
></ha-area-picker>`
: nothing}
<ha-chip-set>
${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;
}

View File

@ -13,6 +13,7 @@ interface BaseRenameDialogParams {
}
export interface EntityRegistryUpdate {
area: string;
labels: string[];
category: string;
}

View File

@ -950,6 +950,7 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
automation: this._entityRegistryUpdate.category || null,
},
labels: this._entityRegistryUpdate.labels || [],
area_id: this._entityRegistryUpdate.area || null,
});
}
}

View File

@ -919,6 +919,7 @@ export class HaScriptEditor extends SubscribeMixin(
script: this._entityRegistryUpdate.category || null,
},
labels: this._entityRegistryUpdate.labels || [],
area_id: this._entityRegistryUpdate.area || null,
});
}

View File

@ -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": {