From c2114f083afeb1ac2cc28e9a83f3a9c591b59a1f Mon Sep 17 00:00:00 2001 From: Grant Ammons Date: Fri, 3 Mar 2017 18:30:06 -0500 Subject: Add priority feature Now, todos have a priority flag. When listed, these todos will be bolded and italic. You can list todos by priority by running `todolist l p`. --- todolist/todo_list.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'todolist/todo_list.go') diff --git a/todolist/todo_list.go b/todolist/todo_list.go index d7e1f83..71484c6 100644 --- a/todolist/todo_list.go +++ b/todolist/todo_list.go @@ -63,6 +63,20 @@ func (t *TodoList) IndexOf(todoToFind *Todo) int { return -1 } +func (t *TodoList) Prioritize(id int) { + todo := t.FindById(id) + todo.IsPriority = true + t.Delete(id) + t.Data = append(t.Data, todo) +} + +func (t *TodoList) Unprioritize(id int) { + todo := t.FindById(id) + todo.IsPriority = false + t.Delete(id) + t.Data = append(t.Data, todo) +} + type ByDate []*Todo func (a ByDate) Len() int { return len(a) } -- cgit v1.3