Fix show_empty: false cards not showing at all. Fix #34

This commit is contained in:
Thomas Lovén 2019-11-13 21:27:40 +01:00
parent 01e22c1e3f
commit fd42fed1d1
2 changed files with 17 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -16,9 +16,14 @@ class AutoEntities extends LitElement {
throw new Error("Invalid configuration");
}
this._config = config;
this._entities = [];
this.cardConfig = {entities: [], ...config.card};
if(!this._config) {
this._config = config;
this.cardConfig = {entities: [], ...config.card};
this.entities = [];
} else {
this._config = config;
this.hass = this.hass;
}
}
async _getEntities()
@ -109,6 +114,14 @@ class AutoEntities extends LitElement {
{
this._entities = ent;
this.cardConfig = {...this.cardConfig, entities: this._entities};
if(ent.length === 0 && this._config.show_empty === false) {
this.style.display = "none";
this.style.margin = "0";
} else {
this.style.display = null;
this.style.margin = null;
}
this.requestUpdate();
}
}
get entities() {
@ -140,9 +153,6 @@ class AutoEntities extends LitElement {
}
render() {
if(this.entities.length === 0 && this._config.show_empty === false) {
return html``;
}
return html`
<card-maker
.hass=${this.hass}