Skip to content
Browse files

Display overdue tasks in red

  • Loading branch information...
1 parent 182e27f commit ccb3bdd7e2e9c6711b1e391d9c8a3295342d5107 @samstokes committed
Showing with 16 additions and 5 deletions.
  1. +6 −1 Handler/Root.hs
  2. +4 −0 Model.hs
  3. +2 −0 cassius/tasks.cassius
  4. +3 −3 hamlet/tasks.hamlet
  5. +1 −1 hamlet/tasks/task-tr.hamlet
View
7 Handler/Root.hs
@@ -65,6 +65,11 @@ getTasksR = authed (\userId -> do
now <- liftIO getCurrentTime
let taskTodoToday :: Task -> Bool
taskTodoToday = taskTodo timeZone now
+ taskOverdueToday :: Task -> Bool
+ taskOverdueToday = taskOverdue timeZone now
+ taskDueClass :: Task -> Maybe String
+ taskDueClass task | taskOverdueToday task = Just "overdue"
+ | otherwise = Nothing
let (unsortedDone, pending) = partition (taskDone . fst . snd) tasksEstimates
let done = reverse $ sortBy (compareBy $ taskDoneAt . fst . snd) unsortedDone
@@ -80,7 +85,7 @@ getTasksR = authed (\userId -> do
userTasks userId = selectList [TaskUser ==. userId] [Asc TaskScheduledFor, Desc TaskDoneAt] -- must specify sorts backwards...
taskEstimates taskId = selectList [EstimateTask ==. taskId] []
- taskTr taskTodoToday (taskId, (task, estimates)) = $(widgetFile "tasks/task-tr")
+ taskTr taskTodoToday taskDueClass (taskId, (task, estimates)) = $(widgetFile "tasks/task-tr")
estimatedRemaining :: (Task, [(EstimateId, Estimate)]) -> Int
estimatedRemaining (_, []) = 0
estimatedRemaining (task, ((_, estimate) : _)) = (estimatePomos estimate - taskPomos task) `max` 0
View
4 Model.hs
@@ -74,6 +74,10 @@ taskTodo :: TimeZone -> UTCTime -> Task -> Bool
taskTodo tz now = (<= today) . taskScheduledForDay tz
where today = utcToLocalDay tz now
+taskOverdue :: TimeZone -> UTCTime -> Task -> Bool
+taskOverdue tz now task = not (taskDone task) && taskScheduledForDay tz task < today
+ where today = utcToLocalDay tz now
+
utcToLocalDay :: TimeZone -> UTCTime -> Day
utcToLocalDay tz = localDay . utcToLocalTime tz
View
2 cassius/tasks.cassius
@@ -2,3 +2,5 @@
text-align: left
.task.done .title, .task.done .estimate, .task.done .pomos
text-decoration: line-through
+.task.overdue .title
+ color: red
View
6 hamlet/tasks.hamlet
@@ -7,7 +7,7 @@ $if null todo
$else
<table><tbody>
$forall idAndTaskEstimates <- todo
- ^{taskTr taskTodoToday idAndTaskEstimates}
+ ^{taskTr taskTodoToday taskDueClass idAndTaskEstimates}
<h3
Remaining: #{sum $ map estimatedRemaining $ map snd todo} of
@@ -25,7 +25,7 @@ $if not (null later)
<h2>Later
<table><tbody>
$forall idAndTaskEstimates <- later
- ^{taskTr taskTodoToday idAndTaskEstimates}
+ ^{taskTr taskTodoToday taskDueClass idAndTaskEstimates}
$if not (null doneByDay)
@@ -37,4 +37,4 @@ $if not (null doneByDay)
\ (#{sum $ map taskPomos tasks})
<table><tbody>
$forall idAndTaskEstimates <- snd dayAndTasksEstimates
- ^{taskTr taskTodoToday idAndTaskEstimates}
+ ^{taskTr taskTodoToday taskDueClass idAndTaskEstimates}
View
2 hamlet/tasks/task-tr.hamlet
@@ -1,4 +1,4 @@
-<tr .task .#{taskState task}
+<tr .task .#{taskState task} .#{taskDueClass task}
<td rowspan=2
$if not (taskDone task)
^{oneButton "^" (RaiseTaskR taskId)}

0 comments on commit ccb3bdd

Please sign in to comment.
Something went wrong with that request. Please try again.