Skip to content

Commit

Permalink
add api property for trees
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Sep 28, 2024
1 parent 2609463 commit 0cd6fc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions dooit/ui/widgets/trees/base_tree.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections import defaultdict
from typing import TYPE_CHECKING, Union
from textual.app import events
from textual.widgets import OptionList
from textual.widgets.option_list import Option

Expand All @@ -10,12 +9,16 @@
ModelType = Union[Todo, Workspace]

if TYPE_CHECKING:
from ....ui.tui import Dooit
from ....ui.tui import Dooit, DooitAPI


class BaseTree(OptionList, can_focus=True, inherit_bindings=False):
expanded_nodes = defaultdict(bool)

@property
def api(self) -> "DooitAPI":
return self.tui.api

@property
def tui(self) -> "Dooit":
from ....ui.tui import Dooit
Expand All @@ -42,6 +45,3 @@ def action_cursor_up(self) -> None:
return

return super().action_cursor_up()

async def handle_keypress(self, key: str) -> bool:
return True
4 changes: 2 additions & 2 deletions dooit/ui/widgets/trees/todos_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def _switch_to_workspace(self) -> None:

@property
def formatter(self) -> "TodoFormatter":
return self.app.api.formatter.todos
return self.api.formatter.todos

@property
def layout(self):
return self.app.api.layouts.todo_layout
return self.api.layouts.todo_layout

def add_todo(self) -> str:
todo = self.model.add_todo()
Expand Down

0 comments on commit 0cd6fc6

Please sign in to comment.