Skip to content

Commit

Permalink
Merge pull request #13 from AquaWolf/complete-todo-items
Browse files Browse the repository at this point in the history
complete to-do items by correcting type for uid field
  • Loading branch information
Craftoncu authored Mar 6, 2024
2 parents 32d9b29 + 35bfe63 commit 95022e7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions custom_components/hacs_vikunja_integration/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SCAN_INTERVAL = timedelta(minutes=15)

TODO_STATUS_MAP = {
"needsAction": TodoItemStatus.NEEDS_ACTION, # probably not_started
"needsAction": TodoItemStatus.NEEDS_ACTION, # probably not_started
"completed": TodoItemStatus.COMPLETED,
}
TODO_STATUS_MAP_INV = {v: k for k, v in TODO_STATUS_MAP.items()}
Expand Down Expand Up @@ -53,7 +53,7 @@ def _convert_api_item(item: dict[str, str]) -> TodoItem:
due = datetime.fromisoformat(due_str).date()
return TodoItem(
summary=item["title"],
uid=item["id"],
uid=str(item["id"]),
status=TODO_STATUS_MAP.get(
item.get("status", ""),
TodoItemStatus.NEEDS_ACTION,
Expand All @@ -62,6 +62,7 @@ def _convert_api_item(item: dict[str, str]) -> TodoItem:
description=item.get("notes"),
)


async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
Expand All @@ -81,19 +82,20 @@ async def async_setup_entry(
True,
)


class VikunjaTaskTodoListEntity(
CoordinatorEntity[VikunjaDataUpdateCoordinator], TodoListEntity
):
"""A To-do List representation of the Shopping List."""

_attr_has_entity_name = True
_attr_supported_features = (
# TodoListEntityFeature.CREATE_TODO_ITEM
TodoListEntityFeature.UPDATE_TODO_ITEM
# | TodoListEntityFeature.DELETE_TODO_ITEM
# | TodoListEntityFeature.MOVE_TODO_ITEM
# | TodoListEntityFeature.SET_DUE_DATE_ON_ITEM
# | TodoListEntityFeature.SET_DESCRIPTION_ON_ITEM
# TodoListEntityFeature.CREATE_TODO_ITEM
TodoListEntityFeature.UPDATE_TODO_ITEM
# | TodoListEntityFeature.DELETE_TODO_ITEM
# | TodoListEntityFeature.MOVE_TODO_ITEM
# | TodoListEntityFeature.SET_DUE_DATE_ON_ITEM
# | TodoListEntityFeature.SET_DESCRIPTION_ON_ITEM
)

def __init__(
Expand All @@ -120,7 +122,6 @@ async def async_update_todo_item(self, item: TodoItem) -> None:
"""Update a To-do item."""
uid: str = cast(str, item.uid)
await self.coordinator.client.update_task(
self._project_id,
uid,
item.status == TodoItemStatus.COMPLETED,
)
Expand All @@ -146,6 +147,7 @@ async def async_update_todo_item(self, item: TodoItem) -> None:
# await self.coordinator.api.move(self._task_list_id, uid, previous=previous_uid)
# await self.coordinator.async_refresh()


# def _order_tasks(tasks: list[dict[str, Any]]) -> list[dict[str, Any]]:
# """Order the task items response.

Expand Down

0 comments on commit 95022e7

Please sign in to comment.