From bd7e5a91c15bc377b89e8d2449c1fee769d36cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Wed, 12 Dec 2018 12:34:06 +0100 Subject: [PATCH] Use card-tools. Should fix the problems that sometimes nesting with card-modder doesn't work. --- README.md | 2 ++ layout-card.js | 16 ++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index cd77dbd..26e50ec 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Get more control over the placement of cards ## Instructions +This card requires [card-tools](https://github.com/thomasloven/lovelace-card-tools) to be installed. + This card takes other cards and place them in different layouts. The card works best if used in a view with `panel: true`. diff --git a/layout-card.js b/layout-card.js index e72d7f9..ba8d37f 100644 --- a/layout-card.js +++ b/layout-card.js @@ -26,18 +26,10 @@ class LayoutCard extends Polymer.Element { `; } - makeCard(config) { - let tag = config.type; - if(tag.startsWith("custom:")) - tag = tag.substr(7); - else - tag = `hui-${tag}-card`; - let card = document.createElement(tag); - card.setConfig(config); - return card; - } - setConfig(config) { + if(!window.cardTools) throw new Error(`Can't find card-tools. See https://github.com/thomasloven/lovelace-card-tools`); + window.cardTools.checkVersion(0.1); + this.config = config; this.colnum = 0; @@ -83,7 +75,7 @@ class LayoutCard extends Polymer.Element { this._cards = this.config.cards.map((c) => { if (typeof c === 'string') return c; - let el = this.makeCard(c); + let el = cardTools.createCard(c); if (this._hass) el.hass = this._hass; return el; });