add task respects filters
This commit is contained in:
parent
7b957dd2c0
commit
fb23b5161f
@ -29,6 +29,7 @@ from .utils import (
|
|||||||
get_colored_date,
|
get_colored_date,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
DEFAULT_CATEGORY = "main"
|
||||||
COLUMNS = ("ID", "Task", "Status", "Type", "Due", "Category")
|
COLUMNS = ("ID", "Task", "Status", "Type", "Due", "Category")
|
||||||
column_to_field = {
|
column_to_field = {
|
||||||
0: "ID",
|
0: "ID",
|
||||||
@ -231,11 +232,16 @@ class TT(App):
|
|||||||
self.refresh_tasks()
|
self.refresh_tasks()
|
||||||
|
|
||||||
def action_add_task(self):
|
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(
|
new_task = add_task(
|
||||||
text="New Task",
|
text="New Task",
|
||||||
type="",
|
type=type_,
|
||||||
status=TaskStatus.ZERO.value,
|
status=status,
|
||||||
category="main",
|
category=category,
|
||||||
)
|
)
|
||||||
self.refresh_tasks(restore_cursor=False)
|
self.refresh_tasks(restore_cursor=False)
|
||||||
self.move_cursor_to_task(new_task.id)
|
self.move_cursor_to_task(new_task.id)
|
||||||
|
Loading…
Reference in New Issue
Block a user