Skip to content

Commit

Permalink
feat: add first item
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Sep 22, 2024
1 parent 7f656e5 commit 2dd0744
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion dooit/ui/widgets/trees/model_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,19 @@ def _add_sibling_node(self) -> ModelType:
node.save()
return node

@refresh_tree
def add_first_item(self) -> ModelType:
return self._add_first_item()

def _add_first_item(self) -> ModelType:
raise NotImplementedError

def add_sibling(self):
node = self._add_sibling_node()
if not self._options:
node = self.add_first_item()
else:
node = self._add_sibling_node()

self.highlight_id(node.uuid)
self.start_edit("description")

Expand Down
3 changes: 3 additions & 0 deletions dooit/ui/widgets/trees/todos_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ def add_todo(self) -> str:
self.add_option(Option(render.prompt, id=render.id))
return todo.uuid

def _add_first_item(self) -> Todo:
return self.model.add_todo()

def _create_child_node(self) -> Todo:
return self.current_model.add_todo()
3 changes: 3 additions & 0 deletions dooit/ui/widgets/trees/workspaces_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ def add_workspace(self) -> str:

def _create_child_node(self) -> Workspace:
return self.current_model.add_workspace()

def _add_first_item(self) -> Workspace:
return self.model.add_workspace()

0 comments on commit 2dd0744

Please sign in to comment.