Compare commits

...

2 Commits

@ -34,7 +34,7 @@ class Board:
self.read_yaml(file)
def read_yaml(self, file='.board.yaml'):
def read_yaml(self, file):
""" Read the yaml file in and set up the data
Arguments:
@ -52,6 +52,24 @@ class Board:
self.tasks[self.columns.index(task['column'])].append(
Task(task['summary'], task['score'], task['description']))
def write_yaml(self, file):
""" Write the yaml file
Arguments:
file - yaml file to write to
"""
# Set up data to write out
data = dict()
data['columns'] = self.columns
data['tasks'] = list()
for col,task_list in zip(self.columns, self.tasks):
for task in task_list:
data['tasks'].append({'column':col, 'summary':task.summary, 'score':task.score,
'description':task.description})
with open(file, 'w') as f:
yaml.dump(data, f)
def move_task(self, col_index, task_index, direction):

@ -34,9 +34,15 @@ EditColScreen {
}
.header {
content-align: center top;
color: #ebdbb9;
text-style: underline;
}
.header-focused {
content-align: center top;
color: #458588;
text-style: bold underline;
text-style: underline;
}
ListItem{

@ -48,6 +48,7 @@ class EditTaskScreen(Screen):
"""
BINDINGS = [
Binding('ctrl+s', 'save', 'Save Changes', priority=True),
Binding('escape', 'exit', 'Exit Without Changes', priority=True),
]
def __init__(self,text):
"""
@ -82,6 +83,9 @@ class EditTaskScreen(Screen):
self.text.description = query.nodes[0].text
self.dismiss(self.text)
def action_exit(self):
self.dismiss(None)
class EditColScreen(Screen):
"""
This is a screen used to edit the name of a task
@ -154,14 +158,26 @@ class KanbanForm(App):
else:
col_class = 'last-column'
with Vertical(classes=col_class):
yield Static(col, classes='header')
if i == 0:
yield Static(col, classes='header-focused')
else:
yield Static(col, classes='header')
yield TaskList(
*[ListItem(Label(task.summary)) for task in self.board.get_tasks()[i]])
# Now make all TaskLists except the first have no highlights
def action_fnext(self):
""" Focus next column"""
query = self.query(selector=Static)
query = [node for node in query.nodes if str(node) == 'Static()']
icol, _ = self.get_col_task()
query[icol].classes="header"
self.children[0].focus_next()
try:
query[icol+1].classes="header-focused"
except IndexError:
query[0].classes="header-focused"
def action_move_up(self):
icol, itask = self.get_col_task()
@ -178,7 +194,15 @@ class KanbanForm(App):
def action_fprev(self):
""" Focus previous column """
query = self.query(selector=Static)
query = [node for node in query.nodes if str(node) == 'Static()']
icol, _ = self.get_col_task()
query[icol].classes="header"
self.children[0].focus_previous()
try:
query[icol-1].classes="header-focused"
except IndexError:
query[-1].classes="header-focused"
def action_move_down(self):
icol, itask = self.get_col_task()
@ -217,7 +241,7 @@ class KanbanForm(App):
def action_exit(self):
""" Exit the application """
self.board.write_md()
self.board.write_yaml(file='.board.yaml')
self.exit()
def get_col_task(self):
@ -233,8 +257,9 @@ class KanbanForm(App):
if focused_col == child:
col_index = i
# Now get the indext of the item in the list
# Now get the index of the item in the list
to_move = focused_col.highlighted_child
task_index = None
for i, child in enumerate(focused_col.children):
if to_move == child:
task_index = i
@ -246,17 +271,19 @@ class KanbanForm(App):
task and the board class
"""
icol, itask = self.get_col_task()
self.focused.highlighted_child.children[0].update(task.summary)
self.board.update_task(icol, itask, task)
if task:
icol, itask = self.get_col_task()
self.focused.highlighted_child.children[0].update(task.summary)
self.board.update_task(icol, itask, task)
def new_task(self, task):
""" This function adds a new task to our board
"""
icol,_ = self.get_col_task()
self.focused.mount(ListItem(Label(task.summary)))
self.board.add_task(icol, task)
self.focused.highlighted_child
if task:
icol,_ = self.get_col_task()
self.focused.mount(ListItem(Label(task.summary)))
self.board.add_task(icol, task)
self.focused.highlighted_child
# def on_key(self):
# with open('log','a') as f:

Loading…
Cancel
Save