add task respects filters

This commit is contained in:
James Turk 2025-01-05 01:09:42 -06:00
parent 7b957dd2c0
commit fb23b5161f

View File

@ -29,6 +29,7 @@ from .utils import (
get_colored_date,
)
DEFAULT_CATEGORY = "main"
COLUMNS = ("ID", "Task", "Status", "Type", "Due", "Category")
column_to_field = {
0: "ID",
@ -231,11 +232,16 @@ class TT(App):
self.refresh_tasks()
def action_add_task(self):
# if filtering on type, status, or category
# the new task should use the selected value
category = self.filters.get("category", DEFAULT_CATEGORY)
status = self.filters.get("status", TaskStatus.ZERO.value).split(",")[0]
type_ = self.filters.get("type", "").split(",")[0]
new_task = add_task(
text="New Task",
type="",
status=TaskStatus.ZERO.value,
category="main",
type=type_,
status=status,
category=category,
)
self.refresh_tasks(restore_cursor=False)
self.move_cursor_to_task(new_task.id)