Do not clear alias when editing automation action, condition or trigger (#18114)

This commit is contained in:
Paul Bottein 2023-10-05 11:23:44 +02:00 committed by GitHub
parent 32bc8bd01d
commit d7f1e9d091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 3 deletions

View File

@ -391,7 +391,10 @@ export default class HaAutomationActionRow extends LitElement {
></ha-yaml-editor>
`
: html`
<div @ui-mode-not-available=${this._handleUiModeNotAvailable}>
<div
@ui-mode-not-available=${this._handleUiModeNotAvailable}
@value-changed=${this._onUiChanged}
>
${dynamicElement(`ha-automation-action-${type}`, {
hass: this.hass,
action: this.action,
@ -530,6 +533,15 @@ export default class HaAutomationActionRow extends LitElement {
fireEvent(this, "value-changed", { value: ev.detail.value });
}
private _onUiChanged(ev: CustomEvent) {
ev.stopPropagation();
const value = {
...(this.action.alias ? { alias: this.action.alias } : {}),
...ev.detail.value,
};
fireEvent(this, "value-changed", { value });
}
private _switchUiMode() {
this._warnings = undefined;
this._yamlMode = false;

View File

@ -54,6 +54,7 @@ export class HaSceneAction extends LitElement implements ActionElement {
ev.stopPropagation();
fireEvent(this, "value-changed", {
value: {
...this.action,
service: "scene.turn_on",
target: {
entity_id: ev.detail.value,

View File

@ -51,6 +51,7 @@ export class HaPlayMediaAction extends LitElement implements ActionElement {
ev.stopPropagation();
fireEvent(this, "value-changed", {
value: {
...this.action,
service: "media_player.play_media",
target: { entity_id: ev.detail.value.entity_id },
data: {

View File

@ -62,7 +62,7 @@ export default class HaAutomationConditionEditor extends LitElement {
></ha-yaml-editor>
`
: html`
<div>
<div @value-changed=${this._onUiChanged}>
${dynamicElement(
`ha-automation-condition-${condition.condition}`,
{
@ -86,6 +86,15 @@ export default class HaAutomationConditionEditor extends LitElement {
fireEvent(this, "value-changed", { value: ev.detail.value, yaml: true });
}
private _onUiChanged(ev: CustomEvent) {
ev.stopPropagation();
const value = {
...(this.condition.alias ? { alias: this.condition.alias } : {}),
...ev.detail.value,
};
fireEvent(this, "value-changed", { value });
}
static styles = haStyle;
}

View File

@ -350,7 +350,10 @@ export default class HaAutomationTriggerRow extends LitElement {
</ha-textfield>
`
: ""}
<div @ui-mode-not-available=${this._handleUiModeNotAvailable}>
<div
@ui-mode-not-available=${this._handleUiModeNotAvailable}
@value-changed=${this._onUiChanged}
>
${dynamicElement(
`ha-automation-trigger-${this.trigger.platform}`,
{
@ -562,6 +565,15 @@ export default class HaAutomationTriggerRow extends LitElement {
fireEvent(this, "value-changed", { value: ev.detail.value });
}
private _onUiChanged(ev: CustomEvent) {
ev.stopPropagation();
const value = {
...(this.trigger.alias ? { alias: this.trigger.alias } : {}),
...ev.detail.value,
};
fireEvent(this, "value-changed", { value });
}
private _switchUiMode() {
this._warnings = undefined;
this._yamlMode = false;