Reload layout after loading. Fix #37
This commit is contained in:
parent
fd42fed1d1
commit
52b2a77bfa
File diff suppressed because one or more lines are too long
2
package-lock.json
generated
2
package-lock.json
generated
@ -627,7 +627,7 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"card-tools": {
|
"card-tools": {
|
||||||
"version": "github:thomasloven/lovelace-card-tools#4bcbb48158dc6ee1cfa767c25125fe84c0ea32df",
|
"version": "github:thomasloven/lovelace-card-tools#605caa906c46340599614aaf9d4e934aabc19b15",
|
||||||
"from": "github:thomasloven/lovelace-card-tools"
|
"from": "github:thomasloven/lovelace-card-tools"
|
||||||
},
|
},
|
||||||
"chalk": {
|
"chalk": {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack",
|
"build": "webpack",
|
||||||
"watch": "webpack --watch --mode=development",
|
"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",
|
"author": "Thomas Lovén",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
18
src/main.js
18
src/main.js
@ -3,6 +3,7 @@ import "card-tools/src/card-maker";
|
|||||||
import { entity_filter } from "./filter";
|
import { entity_filter } from "./filter";
|
||||||
import { entity_sorter } from "./sort";
|
import { entity_sorter } from "./sort";
|
||||||
import { getData } from "card-tools/src/devices";
|
import { getData } from "card-tools/src/devices";
|
||||||
|
import { fireEvent } from "card-tools/src/event";
|
||||||
|
|
||||||
class AutoEntities extends LitElement {
|
class AutoEntities extends LitElement {
|
||||||
|
|
||||||
@ -11,11 +12,10 @@ class AutoEntities extends LitElement {
|
|||||||
hass: {},
|
hass: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
async setConfig(config) {
|
setConfig(config) {
|
||||||
if(!config || !config.card) {
|
if(!config || !config.card) {
|
||||||
throw new Error("Invalid configuration");
|
throw new Error("Invalid configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this._config) {
|
if(!this._config) {
|
||||||
this._config = config;
|
this._config = config;
|
||||||
this.cardConfig = {entities: [], ...config.card};
|
this.cardConfig = {entities: [], ...config.card};
|
||||||
@ -160,14 +160,16 @@ class AutoEntities extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCardSize() {
|
getCardSize() {
|
||||||
|
let len = 0;
|
||||||
if(this.querySelector("card-maker") && this.querySelector("card-maker").getCardSize)
|
if(this.querySelector("card-maker") && this.querySelector("card-maker").getCardSize)
|
||||||
return this.querySelector("card-maker").getCardSize();
|
len = this.querySelector("card-maker").getCardSize();
|
||||||
if(this.entities.length)
|
if(len === 1 && this.entities.length)
|
||||||
return this.entities.length;
|
len = this.entities.length;
|
||||||
if(this._config.filter && this._config.filter.include)
|
if(len === 0 && this._config.filter && this._config.filter.include)
|
||||||
return Object.keys(this._config.filter.include).length;
|
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', {});
|
Loading…
x
Reference in New Issue
Block a user