From 8044ff8dffc3cd914345fda2254d8e69ff29b11f Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 14 Nov 2023 14:54:14 +0100 Subject: [PATCH] Add todo entity_id in URL --- src/panels/todo/ha-panel-todo.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/panels/todo/ha-panel-todo.ts b/src/panels/todo/ha-panel-todo.ts index 19810c70d925..c3cab188bf09 100644 --- a/src/panels/todo/ha-panel-todo.ts +++ b/src/panels/todo/ha-panel-todo.ts @@ -45,6 +45,9 @@ import { HomeAssistant } from "../../types"; import { HuiErrorCard } from "../lovelace/cards/hui-error-card"; import { createCardElement } from "../lovelace/create-element/create-card-element"; import { LovelaceCard } from "../lovelace/types"; +import { navigate } from "../../common/navigate"; +import { createSearchParam } from "../../common/url/search-params"; +import { constructUrlCurrentPath } from "../../common/url/construct-url"; @customElement("ha-panel-todo") class PanelTodo extends LitElement { @@ -114,7 +117,6 @@ class PanelTodo extends LitElement { protected updated(changedProperties: PropertyValues): void { super.updated(changedProperties); - if (changedProperties.has("_entityId")) { this._createCard(); } @@ -127,8 +129,12 @@ class PanelTodo extends LitElement { private _createCard(): void { if (!this._entityId) { this._card = undefined; + navigate(constructUrlCurrentPath("")); return; } + navigate( + constructUrlCurrentPath(createSearchParam({ entity_id: this._entityId })) + ); this._card = createCardElement({ type: "todo-list", entity: this._entityId,