Skip to content

Commit

Permalink
Add todo entity_id in URL
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Nov 14, 2023
1 parent d3f6ebd commit 8044ff8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/panels/todo/ha-panel-todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -114,7 +117,6 @@ class PanelTodo extends LitElement {

protected updated(changedProperties: PropertyValues): void {
super.updated(changedProperties);

if (changedProperties.has("_entityId")) {
this._createCard();
}
Expand All @@ -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,
Expand Down

0 comments on commit 8044ff8

Please sign in to comment.