Lovelace: entity-filter: hide card when entities[] empty (#1373)

* Implements https://github.com/home-assistant/ui-schema/issues/48

Fixed lint

* Updates based on review

Reset display on new config

Fixed reset as setConfig was not being called

Fixed lint
This commit is contained in:
Marius 2018-07-01 18:55:27 +02:00 committed by Paulus Schoutsen
parent 76256699e0
commit e410274684

View File

@ -79,10 +79,16 @@ class HuiEntitiesCard extends PolymerElement {
_updateCardConfig(element) {
if (!element || element.tagName === 'HUI-ERROR-CARD' || !this.hass) return;
const entitiesList = this._getEntities(this.hass, this._config.filter);
if (entitiesList.length === 0) {
this.style.display = (this._config.show_empty === false) ? 'none' : 'block';
} else {
this.style.display = 'block';
}
element.setConfig(Object.assign(
{},
element._filterRawConfig,
{ entities: this._getEntities(this.hass, this._config.filter) }
{ entities: entitiesList }
));
}
}