From 832f4ba6cdcc5a63a38430864fab6684fd7046d9 Mon Sep 17 00:00:00 2001 From: Marius Date: Sun, 15 Jul 2018 15:05:32 +0300 Subject: [PATCH] Make custom cards work as panel (#1447) * Make custom cards work as panel * Fixed some errors and implemented suggestion from comments --- src/panels/lovelace/hui-root.js | 8 +++++++- src/panels/lovelace/hui-view.js | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/panels/lovelace/hui-root.js b/src/panels/lovelace/hui-root.js index cf7f0acae2..6532051042 100644 --- a/src/panels/lovelace/hui-root.js +++ b/src/panels/lovelace/hui-root.js @@ -23,6 +23,7 @@ import '../../components/ha-icon.js'; import { loadModule, loadJS } from '../../common/dom/load_resource.js'; import './hui-unused-entities.js'; import './hui-view.js'; +import debounce from '../../common/util/debounce.js'; import createCardElement from './common/create-card-element.js'; @@ -105,7 +106,7 @@ class HUIRoot extends NavigateMixin(EventsMixin(PolymerElement)) { -
+
`; } @@ -140,6 +141,11 @@ class HUIRoot extends NavigateMixin(EventsMixin(PolymerElement)) { }; } + constructor() { + super(); + this._debouncedConfigChanged = debounce(() => this._selectView(this._curView), 100); + } + _routeChanged(route) { const views = this.config && this.config.views; if (route.path === '' && route.prefix === '/lovelace' && views) { diff --git a/src/panels/lovelace/hui-view.js b/src/panels/lovelace/hui-view.js index df52ddbb52..a815adef68 100644 --- a/src/panels/lovelace/hui-view.js +++ b/src/panels/lovelace/hui-view.js @@ -4,7 +4,6 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js'; import '../../components/entity/ha-state-label-badge.js'; import applyThemesOnElement from '../../common/dom/apply_themes_on_element.js'; -import debounce from '../../common/util/debounce.js'; import createCardElement from './common/create-card-element'; @@ -62,7 +61,7 @@ class HUIView extends PolymerElement { }
-
+
`; } @@ -89,7 +88,6 @@ class HUIView extends PolymerElement { super(); this._cards = []; this._badges = []; - this._debouncedConfigChanged = debounce(this._configChanged, 100); } _createBadges(config) {