Moved todo due date text into helper method

This commit is contained in:
Phil Hughes 2016-09-23 17:28:06 +01:00
parent 08b7480f51
commit a3abfb9708
2 changed files with 7 additions and 5 deletions

View File

@ -114,6 +114,12 @@ module TodosHelper
selected_type ? selected_type[:text] : default_type
end
def todo_due_date(todo)
is_due_today = todo.target.due_date.try(:today?)
"Due #{is_due_today ? "today" : todo.target.due_date.to_s(:medium)}"
end
private
def show_todo_state?(todo)

View File

@ -25,11 +25,7 @@
- is_overdue = todo.target.try(:overdue?)
·
%span{ class: [('text-warning' if is_due_today), ('text-danger' if is_overdue)] }
Due
- if is_due_today
today
- else
= todo.target.due_date.to_s(:medium)
= todo_due_date(todo)
.todo-body
.todo-note