Add support for subtasks

This commit is contained in:
2017-12-11 22:28:04 -08:00
parent 7513035003
commit 4cb283b890
6 changed files with 58 additions and 33 deletions

View File

@@ -1,14 +1,14 @@
palette = [
('selected', 'standout', ''),
('selected workspace', 'standout,bold', ''),
('atm_section', 'white,bold', 'dark blue'),
('author', 'bold,dark blue', ''),
('custom_fields', 'dark red', ''),
('header', 'bold,light green', ''),
('secondary', 'light green', ''),
('task', 'light green', ''),
('project', 'yellow', ''),
('section', 'dark green,bold', ''),
('atm_section', 'white,bold', 'dark blue'),
('selected', 'standout', ''),
('task', 'light green', ''),
('text', '', ''),
('workspace', 'white', 'dark blue'),
('pager', 'standout', ''),
]
keys = {

View File

@@ -1,5 +1,7 @@
import urwid
from ui.task_list import TaskRow
class TaskDetails(object):
def __init__(self, task, stories, on_subtask_click, on_project_click,
on_comment):
@@ -8,17 +10,28 @@ class TaskDetails(object):
self.on_project_click = on_project_click,
self.on_comment = on_comment
self.details = urwid.Pile([
('pack', urwid.Text(('task', task.name()))),
('pack', urwid.Divider('-')),
('weight', 1, Memberships(task, on_subtask_click, on_project_click) \
.component()),
('pack', urwid.Divider('-')),
('pack', CustomFields(task).component()),
('pack', urwid.Divider('-')),
('weight', 20, urwid.Filler(urwid.Text(task.description()))),
('weight', 5, urwid.Filler(Stories(stories).component()))
])
body = [
urwid.Text(('task', task.name())),
urwid.Divider('-'),
Memberships(task, on_subtask_click, on_project_click).component(),
urwid.Divider('-'),
CustomFields(task).component(),
urwid.Divider('='),
urwid.Text(task.description()),
urwid.Divider('-'),
]
if task.subtasks():
body.append(urwid.Pile([
TaskRow(t, on_subtask_click) for t in task.subtasks()
]))
body = body + [
urwid.Divider('-'),
Stories(stories).component()
]
self.details = urwid.ListBox(urwid.SimpleFocusListWalker(body))
def component(self):
return self.details
@@ -35,17 +48,17 @@ class Memberships(object):
on_press = lambda x: on_subtask_click(task.parent().id())
))
self.memberships = urwid.ListBox(
urwid.SimpleFocusListWalker(components)
)
self.memberships = urwid.Pile(components)
def component(self):
return self.memberships
class CustomFields(object):
def __init__(self, task):
components = [urwid.Text('%s: %s' % (f.name(), f.string_value()))
for f in task.custom_fields()]
components = [urwid.Text([
('custom_fields', f.name() + ': '),
f.string_value()
]) for f in task.custom_fields()]
self.custom_fields = urwid.Pile(components)
@@ -54,7 +67,11 @@ class CustomFields(object):
class Stories(object):
def __init__(self, stories):
components = [urwid.Text(s.string_value()) for s in stories]
components = [urwid.Text([
('author', s.creator()),
s.text(),
'\n'
]) for s in stories]
self.stories = urwid.Pile(components)

View File

@@ -53,7 +53,7 @@ class TaskRow(urwid.SelectableIcon):
def __init__(self, task, on_click):
self.on_click = on_click
self.task = task
style = 'section' if task.name()[-1] == ':' else 'task'
style = 'section' if task.name() and task.name()[-1] == ':' else 'task'
super(TaskRow, self).__init__((style, task.name()))
def keypress(self, size, key):