Add column highlighting

feature/make_board_screen
Alex Selimov 1 year ago
parent 779ddca11f
commit c7e180459b

@ -34,7 +34,7 @@ class Board:
self.read_yaml(file) 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 """ Read the yaml file in and set up the data
Arguments: Arguments:
@ -52,6 +52,24 @@ class Board:
self.tasks[self.columns.index(task['column'])].append( self.tasks[self.columns.index(task['column'])].append(
Task(task['summary'], task['score'], task['description'])) 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): def move_task(self, col_index, task_index, direction):

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

@ -154,14 +154,26 @@ class KanbanForm(App):
else: else:
col_class = 'last-column' col_class = 'last-column'
with Vertical(classes=col_class): 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( yield TaskList(
*[ListItem(Label(task.summary)) for task in self.board.get_tasks()[i]]) *[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): def action_fnext(self):
""" Focus next column""" """ 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() self.children[0].focus_next()
try:
query[icol+1].classes="header-focused"
except IndexError:
query[0].classes="header-focused"
def action_move_up(self): def action_move_up(self):
icol, itask = self.get_col_task() icol, itask = self.get_col_task()
@ -178,7 +190,15 @@ class KanbanForm(App):
def action_fprev(self): def action_fprev(self):
""" Focus previous column """ """ 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() self.children[0].focus_previous()
try:
query[icol-1].classes="header-focused"
except IndexError:
query[-1].classes="header-focused"
def action_move_down(self): def action_move_down(self):
icol, itask = self.get_col_task() icol, itask = self.get_col_task()
@ -217,7 +237,7 @@ class KanbanForm(App):
def action_exit(self): def action_exit(self):
""" Exit the application """ """ Exit the application """
self.board.write_md() self.board.write_yaml(file='.board.yaml')
self.exit() self.exit()
def get_col_task(self): def get_col_task(self):
@ -233,8 +253,9 @@ class KanbanForm(App):
if focused_col == child: if focused_col == child:
col_index = i 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 to_move = focused_col.highlighted_child
task_index = None
for i, child in enumerate(focused_col.children): for i, child in enumerate(focused_col.children):
if to_move == child: if to_move == child:
task_index = i task_index = i