mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Keep todo item selected when checked/unchecked (#19168)
* Keep todo item selected when checked/unchecked * update label when in reoder mode
This commit is contained in:
parent
b11563d618
commit
1916dff57b
@ -1,4 +1,5 @@
|
|||||||
import "@material/mwc-list/mwc-list";
|
import "@material/mwc-list/mwc-list";
|
||||||
|
import type { List } from "@material/mwc-list/mwc-list";
|
||||||
import {
|
import {
|
||||||
mdiClock,
|
mdiClock,
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
@ -229,7 +230,7 @@ export class HuiTodoListCard extends LitElement implements LovelaceCard {
|
|||||||
: nothing}
|
: nothing}
|
||||||
</div>
|
</div>
|
||||||
${uncheckedItems.length
|
${uncheckedItems.length
|
||||||
? html` <div class="header">
|
? html`<div class="header">
|
||||||
<span>
|
<span>
|
||||||
${this.hass!.localize(
|
${this.hass!.localize(
|
||||||
"ui.panel.lovelace.cards.todo-list.unchecked_items"
|
"ui.panel.lovelace.cards.todo-list.unchecked_items"
|
||||||
@ -248,7 +249,9 @@ export class HuiTodoListCard extends LitElement implements LovelaceCard {
|
|||||||
graphic="icon"
|
graphic="icon"
|
||||||
>
|
>
|
||||||
${this.hass!.localize(
|
${this.hass!.localize(
|
||||||
"ui.panel.lovelace.cards.todo-list.reorder_items"
|
this._reordering
|
||||||
|
? "ui.panel.lovelace.cards.todo-list.exit_reorder_items"
|
||||||
|
: "ui.panel.lovelace.cards.todo-list.reorder_items"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="graphic"
|
slot="graphic"
|
||||||
@ -466,18 +469,29 @@ export class HuiTodoListCard extends LitElement implements LovelaceCard {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _completeItem(ev): void {
|
private async _completeItem(ev): Promise<void> {
|
||||||
const item = this._getItem(ev.currentTarget.itemId);
|
const item = this._getItem(ev.currentTarget.itemId);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateItem(this.hass!, this._entityId!, {
|
await updateItem(this.hass!, this._entityId!, {
|
||||||
...item,
|
...item,
|
||||||
status:
|
status:
|
||||||
item.status === TodoItemStatus.NeedsAction
|
item.status === TodoItemStatus.NeedsAction
|
||||||
? TodoItemStatus.Completed
|
? TodoItemStatus.Completed
|
||||||
: TodoItemStatus.NeedsAction,
|
: TodoItemStatus.NeedsAction,
|
||||||
});
|
});
|
||||||
|
await this.updateComplete;
|
||||||
|
const newList: List = this.shadowRoot!.querySelector(
|
||||||
|
item.status === TodoItemStatus.NeedsAction ? "#checked" : "#unchecked"
|
||||||
|
)!;
|
||||||
|
await newList.updateComplete;
|
||||||
|
const items =
|
||||||
|
item.status === TodoItemStatus.NeedsAction
|
||||||
|
? this._getCheckedItems(this._items)
|
||||||
|
: this._getUncheckedItems(this._items);
|
||||||
|
const index = items.findIndex((itm) => itm.uid === item.uid);
|
||||||
|
newList.focusItemAtIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _clearCompletedItems(): Promise<void> {
|
private async _clearCompletedItems(): Promise<void> {
|
||||||
|
@ -99,7 +99,6 @@ class DialogTodoItemEditor extends LitElement {
|
|||||||
open
|
open
|
||||||
@closed=${this.closeDialog}
|
@closed=${this.closeDialog}
|
||||||
scrimClickAction
|
scrimClickAction
|
||||||
escapeKeyAction
|
|
||||||
.heading=${createCloseHeading(
|
.heading=${createCloseHeading(
|
||||||
this.hass,
|
this.hass,
|
||||||
isCreate
|
isCreate
|
||||||
|
@ -4768,6 +4768,7 @@
|
|||||||
"add_item": "Add item",
|
"add_item": "Add item",
|
||||||
"today": "Today",
|
"today": "Today",
|
||||||
"reorder_items": "Reorder items",
|
"reorder_items": "Reorder items",
|
||||||
|
"exit_reorder_items": "Exit reorder mode",
|
||||||
"drag_and_drop": "Drag and drop",
|
"drag_and_drop": "Drag and drop",
|
||||||
"delete_item": "Delete item",
|
"delete_item": "Delete item",
|
||||||
"delete_confirm_title": "Remove completed items?",
|
"delete_confirm_title": "Remove completed items?",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user