mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-10 19:40:25 +00:00
Catch errors in preview and fix entity picker (#2183)
* Catch errors in preview and fix entity picker * Replace add button with entity-picker
This commit is contained in:
@@ -42,16 +42,23 @@ export class HuiEntityEditor extends LitElement {
|
||||
`;
|
||||
})
|
||||
}
|
||||
<ha-entity-picker
|
||||
.hass="${this.hass}"
|
||||
@change="${this._addEntity}"
|
||||
></ha-entity-picker>
|
||||
</div>
|
||||
<paper-button noink raised @click="${this._addEntity}"
|
||||
>Add Entity</paper-button
|
||||
>
|
||||
`;
|
||||
}
|
||||
|
||||
private _addEntity() {
|
||||
const newConfigEntities = this.entities!.concat({ entity: "" });
|
||||
|
||||
private _addEntity(ev: Event): void {
|
||||
const target = ev.target! as EditorTarget;
|
||||
if (target.value === "") {
|
||||
return;
|
||||
}
|
||||
const newConfigEntities = this.entities!.concat({
|
||||
entity: target.value as string,
|
||||
});
|
||||
target.value = "";
|
||||
fireEvent(this, "entities-changed", { entities: newConfigEntities });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user