Commit 8ea18c37 authored by Phil Hughes's avatar Phil Hughes

Moved todo due date to helper method

parent a3abfb97
...@@ -115,9 +115,14 @@ module TodosHelper ...@@ -115,9 +115,14 @@ module TodosHelper
end end
def todo_due_date(todo) def todo_due_date(todo)
return unless todo.target.try(:due_date)
is_due_today = todo.target.due_date.try(:today?) is_due_today = todo.target.due_date.try(:today?)
is_overdue = todo.target.try(:overdue?)
"Due #{is_due_today ? "today" : todo.target.due_date.to_s(:medium)}" content_tag :span, class: [('text-warning' if is_due_today), ('text-danger' if is_overdue)] do
"Due #{is_due_today ? "today" : todo.target.due_date.to_s(:medium)}"
end
end end
private private
......
...@@ -19,13 +19,7 @@ ...@@ -19,13 +19,7 @@
(removed) (removed)
· #{time_ago_with_tooltip(todo.created_at)} · #{time_ago_with_tooltip(todo.created_at)}
· #{todo_due_date(todo)}
- if todo.target.try(:due_date)
- is_due_today = todo.target.due_date.try(:today?)
- is_overdue = todo.target.try(:overdue?)
·
%span{ class: [('text-warning' if is_due_today), ('text-danger' if is_overdue)] }
= todo_due_date(todo)
.todo-body .todo-body
.todo-note .todo-note
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment