Keep area field next to use device area field (#16324)

This commit is contained in:
Paul Bottein 2023-04-26 16:54:59 +02:00 committed by GitHub
parent 8cf8c41698
commit 5cd3ce66f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -608,11 +608,10 @@ export class EntityRegistrySettingsEditor extends LitElement {
.disabled=${this.disabled} .disabled=${this.disabled}
@input=${this._entityIdChanged} @input=${this._entityIdChanged}
></ha-textfield> ></ha-textfield>
${!this.entry.device_id || this._areaId || this._noDeviceArea ${!this.entry.device_id
? html`<ha-area-picker ? html`<ha-area-picker
.hass=${this.hass} .hass=${this.hass}
.value=${this._areaId} .value=${this._areaId}
.placeholder=${this._device?.area_id}
.disabled=${this.disabled} .disabled=${this.disabled}
@value-changed=${this._areaPicked} @value-changed=${this._areaPicked}
></ha-area-picker>` ></ha-area-picker>`
@ -794,40 +793,49 @@ export class EntityRegistrySettingsEditor extends LitElement {
${this.entry.device_id ${this.entry.device_id
? html`<ha-settings-row> ? html`<ha-settings-row>
<span slot="heading" <span slot="heading"
>${this.hass.localize( >${this.hass.localize(
"ui.dialogs.entity_registry.editor.use_device_area" "ui.dialogs.entity_registry.editor.use_device_area"
)} )}
${this.hass.devices[this.entry.device_id].area_id ${this.hass.devices[this.entry.device_id].area_id
? `(${ ? `(${
this.hass.areas[ this.hass.areas[
this.hass.devices[this.entry.device_id].area_id! this.hass.devices[this.entry.device_id].area_id!
]?.name ]?.name
})` })`
: ""}</span : ""}</span
> >
<span slot="description" <span slot="description"
>${this.hass.localize( >${this.hass.localize(
"ui.dialogs.entity_registry.editor.change_device_settings", "ui.dialogs.entity_registry.editor.change_device_settings",
{ {
link: html`<button link: html`<button
class="link" class="link"
@click=${this._openDeviceSettings} @click=${this._openDeviceSettings}
> >
${this.hass.localize( ${this.hass.localize(
"ui.dialogs.entity_registry.editor.change_device_area_link" "ui.dialogs.entity_registry.editor.change_device_area_link"
)} )}
</button>`, </button>`,
} }
)}</span )}</span
> >
<ha-switch <ha-switch
.checked=${!this._areaId || this._noDeviceArea} .checked=${!this._areaId || this._noDeviceArea}
.disabled=${this.disabled} .disabled=${this.disabled}
@change=${this._useDeviceAreaChanged} @change=${this._useDeviceAreaChanged}
> >
</ha-switch </ha-switch
></ha-settings-row>` ></ha-settings-row>
${this._areaId || this._noDeviceArea
? html`<ha-area-picker
.hass=${this.hass}
.value=${this._areaId}
.placeholder=${this._device?.area_id}
.disabled=${this.disabled}
@value-changed=${this._areaPicked}
></ha-area-picker>`
: ""} `
: ""} : ""}
`; `;
} }