Permalink
Browse files

Split out done and pending tasks for increased win

  • Loading branch information...
1 parent 39fea14 commit fd784d1701d44e180aceb31c285bc2ed590f2947 @samstokes committed Sep 8, 2011
Showing with 14 additions and 3 deletions.
  1. +2 −0 Handler/Root.hs
  2. +12 −3 hamlet/tasks.hamlet
View
@@ -3,6 +3,7 @@ module Handler.Root where
import Control.Applicative
import Control.Monad
+import Data.List (partition)
import Data.Monoid
import Data.Map (Map)
import qualified Data.Map as M
@@ -42,6 +43,7 @@ getTasksR = maybeAuth >>= getTasksR' where
getTasksR' (Just (userId, user)) = do
tasks <- runDB $ userTasks userId
+ let (done, pending) = partition (taskDone . snd) tasks
estimates <- mapM (runDB . taskEstimates . fst) tasks
let tasksEstimates = M.fromList $ zip (map fst tasks) estimates
((_, taskWidget), enctype) <- generateFormPost $ taskForm userId
View
@@ -1,13 +1,22 @@
<h1>Pomos!
-$if null tasks
- <p>You have no tasks.
+<h2>TODO
+
+$if null pending
+ <p>Nothing to do. Congratulations! Why not take the day off?
$else
<table><tbody>
- $forall idAndTask <- tasks
+ $forall idAndTask <- pending
$with estimates <- M.findWithDefault mempty (fst idAndTask) tasksEstimates
^{taskTr idAndTask estimates}
<form method=POST action=@{TasksR} enctype=#{enctype}
^{taskWidget}
<input type=submit value=Add
+
+$if not (null done)
+ <h2>Done
+ <table><tbody>
+ $forall idAndTask <- done
+ $with estimates <- M.findWithDefault mempty (fst idAndTask) tasksEstimates
+ ^{taskTr idAndTask estimates}

0 comments on commit fd784d1

Please sign in to comment.