Skip to content

Commit

Permalink
Add create todo list button (#18387)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Oct 25, 2023
1 parent 01f51f3 commit f6fddbc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
27 changes: 25 additions & 2 deletions src/panels/todo/ha-panel-todo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { ResizeController } from "@lit-labs/observers/resize-controller";
import "@material/mwc-list";
import { mdiChevronDown, mdiDotsVertical, mdiMicrophone } from "@mdi/js";
import {
mdiChevronDown,
mdiDotsVertical,
mdiMicrophone,
mdiPlus,
} from "@mdi/js";
import {
CSSResultGroup,
LitElement,
Expand Down Expand Up @@ -29,6 +34,8 @@ 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 { fetchIntegrationManifest } from "../../data/integration";
import { showConfigFlowDialog } from "../../dialogs/config-flow/show-dialog-config-flow";

@customElement("ha-panel-todo")
class PanelTodo extends LitElement {
Expand Down Expand Up @@ -131,7 +138,7 @@ class PanelTodo extends LitElement {
</ha-list-item> `
);
return html`
<ha-two-pane-top-app-bar-fixed .pane=${showPane}>
<ha-two-pane-top-app-bar-fixed .pane=${showPane} footer>
<ha-menu-button
slot="navigationIcon"
.hass=${this.hass}
Expand Down Expand Up @@ -160,10 +167,18 @@ class PanelTodo extends LitElement {
</ha-button>
${listItems}
<li divider role="separator"></li>
<ha-list-item graphic="icon" @click=${this._addList}>
<ha-svg-icon .path=${mdiPlus} slot="graphic"></ha-svg-icon>
${this.hass.localize("ui.panel.todo.create_list")}
</ha-list-item>
</ha-button-menu>`
: "Lists"}
</div>
<mwc-list slot="pane" activatable>${listItems}</mwc-list>
<ha-list-item graphic="icon" slot="pane-footer" @click=${this._addList}>
<ha-svg-icon .path=${mdiPlus} slot="graphic"></ha-svg-icon>
${this.hass.localize("ui.panel.todo.create_list")}
</ha-list-item>
<ha-button-menu slot="actionItems">
<ha-icon-button
slot="trigger"
Expand Down Expand Up @@ -192,6 +207,14 @@ class PanelTodo extends LitElement {
this._entityId = ev.currentTarget.entityId;
}

private async _addList(): Promise<void> {
showConfigFlowDialog(this, {
startFlowHandler: "local_todo",
showAdvanced: this.hass.userData?.showAdvanced,
manifest: await fetchIntegrationManifest(this.hass, "local_todo"),
});
}

private _showVoiceCommandDialog(): void {
showVoiceCommandDialog(this, this.hass, { pipeline_id: "last_used" });
}
Expand Down
3 changes: 2 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5511,7 +5511,8 @@
}
},
"todo": {
"start_conversation": "Start conversation"
"start_conversation": "Start conversation",
"create_list": "Create list"
},
"page-authorize": {
"initializing": "Initializing",
Expand Down

0 comments on commit f6fddbc

Please sign in to comment.