Permalink
Browse files

Move task rendering into its own template

  • Loading branch information...
1 parent 35c4075 commit 39fea14e546e799059bc602fb0a576303d81df84 @samstokes committed Sep 8, 2011
Showing with 24 additions and 22 deletions.
  1. +3 −2 Handler/Root.hs
  2. +2 −20 hamlet/tasks.hamlet
  3. +19 −0 hamlet/tasks/task-tr.hamlet
View
@@ -51,6 +51,7 @@ getTasksR = maybeAuth >>= getTasksR' where
userTasks userId = selectList [TaskUser ==. userId] [Asc TaskDone]
taskEstimates taskId = selectList [EstimateTask ==. taskId] []
+ taskTr (taskId, task) estimates = $(widgetFile "tasks/task-tr")
oneButton :: Text -> YesodoroRoute -> Widget
@@ -94,8 +95,8 @@ setTaskDonenessRoute (taskId, task) = route taskId
where route | taskDone task = RestartTaskR
| otherwise = CompleteTaskR
-setTaskDonenessButton :: (TaskId, Task) -> Widget
-setTaskDonenessButton (taskId, task) = oneButton action (route taskId)
+setTaskDonenessButton :: TaskId -> Task -> Widget
+setTaskDonenessButton taskId task = oneButton action (route taskId)
where action = taskActionName task
route | taskDone task = RestartTaskR
| otherwise = CompleteTaskR
View
@@ -5,26 +5,8 @@ $if null tasks
$else
<table><tbody>
$forall idAndTask <- tasks
- <tr .task .#{taskState $ snd idAndTask}
- <th .title rowspan=2>#{taskTitle $ snd idAndTask}
- <td rowspan=2>^{setTaskDonenessButton idAndTask}
- <td rowspan=2>^{oneButton "Delete" (DeleteTaskR $ fst idAndTask)}
- <td>
- $with estimates <- M.findWithDefault mempty (fst idAndTask) tasksEstimates
- $if null estimates
- <form method=POST action=@{TaskAddEstimateR $ fst idAndTask}
- $forall numPomos <- estimateOptions
- <button name=pomos value=#{show numPomos}
- #{show numPomos}
- $else
- $with firstEstimate <- estimatePomos $ snd $ head estimates
- $forall estimate <- replicate firstEstimate undefined
- ❏
- <td rowspan=2>^{oneButton "Pomo" (TaskAddPomoR $ fst idAndTask)}
- <tr .task .#{taskState $ snd idAndTask}
- <td
- $forall pomo <- replicate (taskPomos $ snd idAndTask) undefined
- ✓
+ $with estimates <- M.findWithDefault mempty (fst idAndTask) tasksEstimates
+ ^{taskTr idAndTask estimates}
<form method=POST action=@{TasksR} enctype=#{enctype}
^{taskWidget}
@@ -0,0 +1,19 @@
+<tr .task .#{taskState task}
+ <th .title rowspan=2>#{taskTitle task}
+ <td rowspan=2>^{setTaskDonenessButton taskId task}
+ <td rowspan=2>^{oneButton "Delete" (DeleteTaskR taskId)}
+ <td>
+ $if null estimates
+ <form method=POST action=@{TaskAddEstimateR taskId}
+ $forall numPomos <- estimateOptions
+ <button name=pomos value=#{show numPomos}
+ #{show numPomos}
+ $else
+ $with firstEstimate <- estimatePomos $ snd $ head estimates
+ $forall estimate <- replicate firstEstimate undefined
+ ❏
+ <td rowspan=2>^{oneButton "Pomo" (TaskAddPomoR taskId)}
+<tr .task .#{taskState task}
+ <td
+ $forall pomo <- replicate (taskPomos task) undefined
+ ✓

0 comments on commit 39fea14

Please sign in to comment.