Reload layout after loading. Fix #37

This commit is contained in:
Thomas Lovén 2019-11-14 22:40:26 +01:00
parent fd42fed1d1
commit 52b2a77bfa
4 changed files with 14 additions and 12 deletions

File diff suppressed because one or more lines are too long

2
package-lock.json generated
View File

@ -627,7 +627,7 @@
"dev": true
},
"card-tools": {
"version": "github:thomasloven/lovelace-card-tools#4bcbb48158dc6ee1cfa767c25125fe84c0ea32df",
"version": "github:thomasloven/lovelace-card-tools#605caa906c46340599614aaf9d4e934aabc19b15",
"from": "github:thomasloven/lovelace-card-tools"
},
"chalk": {

View File

@ -6,7 +6,7 @@
"scripts": {
"build": "webpack",
"watch": "webpack --watch --mode=development",
"test": "echo \"Error: no test specified\" && exit 1"
"update-card-tools": "npm uninstall card-tools && npm install thomasloven/lovelace-card-tools"
},
"author": "Thomas Lovén",
"license": "MIT",

View File

@ -3,6 +3,7 @@ import "card-tools/src/card-maker";
import { entity_filter } from "./filter";
import { entity_sorter } from "./sort";
import { getData } from "card-tools/src/devices";
import { fireEvent } from "card-tools/src/event";
class AutoEntities extends LitElement {
@ -11,11 +12,10 @@ class AutoEntities extends LitElement {
hass: {},
};
}
async setConfig(config) {
setConfig(config) {
if(!config || !config.card) {
throw new Error("Invalid configuration");
}
if(!this._config) {
this._config = config;
this.cardConfig = {entities: [], ...config.card};
@ -160,14 +160,16 @@ class AutoEntities extends LitElement {
}
getCardSize() {
let len = 0;
if(this.querySelector("card-maker") && this.querySelector("card-maker").getCardSize)
return this.querySelector("card-maker").getCardSize();
if(this.entities.length)
return this.entities.length;
if(this._config.filter && this._config.filter.include)
len = this.querySelector("card-maker").getCardSize();
if(len === 1 && this.entities.length)
len = this.entities.length;
if(len === 0 && this._config.filter && this._config.filter.include)
return Object.keys(this._config.filter.include).length;
return 1
return len || 1;
}
}
customElements.define('auto-entities', AutoEntities)
customElements.define('auto-entities', AutoEntities);
fireEvent('ll-rebuild', {});