Skip to content

Commit

Permalink
Add support for todo component (#18289)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Oct 23, 2023
1 parent 53b8d1b commit 2b9540f
Show file tree
Hide file tree
Showing 20 changed files with 670 additions and 327 deletions.
9 changes: 9 additions & 0 deletions demo/src/configs/arsaboo/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { DemoConfig } from "../types";

export const demoEntitiesArsaboo: DemoConfig["entities"] = (localize) =>
convertEntities({
"todo.shopping_list": {
entity_id: "todo.shopping_list",
state: "2",
attributes: {
supported_features: 15,
friendly_name: "Shopping List",
icon: "mdi:cart",
},
},
"zone.home": {
entity_id: "zone.home",
state: "zoning",
Expand Down
9 changes: 9 additions & 0 deletions demo/src/configs/jimpower/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { DemoConfig } from "../types";

export const demoEntitiesJimpower: DemoConfig["entities"] = () =>
convertEntities({
"todo.shopping_list": {
entity_id: "todo.shopping_list",
state: "2",
attributes: {
supported_features: 15,
friendly_name: "Shopping List",
icon: "mdi:cart",
},
},
"zone.powertec": {
entity_id: "zone.powertec",
state: "zoning",
Expand Down
9 changes: 9 additions & 0 deletions demo/src/configs/kernehed/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { DemoConfig } from "../types";

export const demoEntitiesKernehed: DemoConfig["entities"] = () =>
convertEntities({
"todo.shopping_list": {
entity_id: "todo.shopping_list",
state: "2",
attributes: {
supported_features: 15,
friendly_name: "Shopping List",
icon: "mdi:cart",
},
},
"zone.anna": {
entity_id: "zone.anna",
state: "zoning",
Expand Down
9 changes: 9 additions & 0 deletions demo/src/configs/teachingbirds/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { DemoConfig } from "../types";

export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () =>
convertEntities({
"todo.shopping_list": {
entity_id: "todo.shopping_list",
state: "2",
attributes: {
supported_features: 15,
friendly_name: "Shopping List",
icon: "mdi:cart",
},
},
"sensor.pollen_grabo": {
entity_id: "sensor.pollen_grabo",
state: "",
Expand Down
4 changes: 2 additions & 2 deletions demo/src/ha-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { mockLovelace } from "./stubs/lovelace";
import { mockMediaPlayer } from "./stubs/media_player";
import { mockPersistentNotification } from "./stubs/persistent_notification";
import { mockRecorder } from "./stubs/recorder";
import { mockShoppingList } from "./stubs/shopping_list";
import { mockTodo } from "./stubs/todo";
import { mockSystemLog } from "./stubs/system_log";
import { mockTemplate } from "./stubs/template";
import { mockTranslations } from "./stubs/translations";
Expand All @@ -49,7 +49,7 @@ export class HaDemo extends HomeAssistantAppEl {
mockTranslations(hass);
mockHistory(hass);
mockRecorder(hass);
mockShoppingList(hass);
mockTodo(hass);
mockSystemLog(hass);
mockTemplate(hass);
mockEvents(hass);
Expand Down
44 changes: 0 additions & 44 deletions demo/src/stubs/shopping_list.ts

This file was deleted.

24 changes: 24 additions & 0 deletions demo/src/stubs/todo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TodoItem, TodoItemStatus } from "../../../src/data/todo";
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";

export const mockTodo = (hass: MockHomeAssistant) => {
hass.mockWS("todo/item/list", () => ({
items: [
{
uid: "12",
summary: "Milk",
status: TodoItemStatus.NeedsAction,
},
{
uid: "13",
summary: "Eggs",
status: TodoItemStatus.NeedsAction,
},
{
uid: "14",
summary: "Oranges",
status: TodoItemStatus.Completed,
},
] as TodoItem[],
}));
};
22 changes: 16 additions & 6 deletions gallery/src/pages/lovelace/shopping-list-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,33 @@ import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, query } from "lit/decorators";
import { provideHass } from "../../../../src/fake_data/provide_hass";
import "../../components/demo-cards";
import { getEntity } from "../../../../src/fake_data/entity";
import { mockTodo } from "../../../../demo/src/stubs/todo";

const ENTITIES = [
getEntity("todo", "shopping_list", "2", {
friendly_name: "Shopping List",
supported_features: 15,
}),
getEntity("todo", "read_only", "2", {
friendly_name: "Read only",
}),
];

const CONFIGS = [
{
heading: "List example",
config: `
- type: shopping-list
entity: todo.shopping_list
`,
},
{
heading: "List with title example",
config: `
- type: shopping-list
title: Shopping List
entity: todo.read_only
`,
},
];
Expand All @@ -32,13 +46,9 @@ class DemoShoppingListEntity extends LitElement {
const hass = provideHass(this._demoRoot);
hass.updateTranslations(null, "en");
hass.updateTranslations("lovelace", "en");
hass.addEntities(ENTITIES);

hass.mockAPI("shopping_list", () => [
{ name: "list", id: 1, complete: false },
{ name: "all", id: 2, complete: false },
{ name: "the", id: 3, complete: false },
{ name: "things", id: 4, complete: true },
]);
mockTodo(hass);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/common/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
mdiCarCoolantLevel,
mdiCash,
mdiChatSleep,
mdiClipboardCheck,
mdiClock,
mdiCloudUpload,
mdiCog,
Expand Down Expand Up @@ -120,6 +121,7 @@ export const FIXED_DOMAIN_ICONS = {
siren: mdiBullhorn,
stt: mdiMicrophoneMessage,
text: mdiFormTextbox,
todo: mdiClipboardCheck,
time: mdiClock,
timer: mdiTimerOutline,
tts: mdiSpeakerMessage,
Expand Down
4 changes: 2 additions & 2 deletions src/components/ha-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import "@material/mwc-button/mwc-button";
import {
mdiBell,
mdiCalendar,
mdiCart,
mdiCellphoneCog,
mdiChartBox,
mdiClipboardList,
mdiClose,
mdiCog,
mdiFormatListBulletedType,
Expand Down Expand Up @@ -81,7 +81,7 @@ const PANEL_ICONS = {
lovelace: mdiViewDashboard,
map: mdiTooltipAccount,
"media-browser": mdiPlayBoxMultiple,
"shopping-list": mdiCart,
todo: mdiClipboardList,
};

const panelSorter = (
Expand Down
58 changes: 0 additions & 58 deletions src/data/shopping-list.ts

This file was deleted.

Loading

0 comments on commit 2b9540f

Please sign in to comment.