Add vote count row and move vote button in to last col

This commit is contained in:
Konrad Merz 2015-03-30 09:39:42 +02:00
parent 44b47b2564
commit 1939329608
3 changed files with 15 additions and 2 deletions

View file

@ -73,3 +73,9 @@ h4 {
.checker {
text-align: center;
}
.count {
text-align: center;
background-color: #819FF7;
color: #fff;
}

View file

@ -25,11 +25,14 @@ render (pollId, pollName, pollDesc) options voters errors = do
H.td "Voted by"
mapM_ renderOption options
mapM_ renderVoter $ M.keys voters
H.tr $ do
H.td $ ""
mapM_ renderVoteCount options
H.tr $ do
H.td $ do
H.input ! A.class_ "input" ! A.placeholder "Vote as" ! A.name "name"
mapM_ renderCheckbox options
H.input ! A.class_ "btn" ! A.type_ "submit" ! A.value "Vote"
H.td $ H.input ! A.class_ "btn" ! A.type_ "submit" ! A.value "Vote"
H.a ! A.class_ "btn" ! A.href "/polls" $ "Back"
H.a ! A.class_ "btn" !
A.href (H.stringValue ("/polls/" ++ (show pollId) ++ "/edit")) $ "Edit"
@ -53,6 +56,10 @@ render (pollId, pollName, pollDesc) options voters errors = do
else H.td ! A.class_ "false" $ ""
Nothing -> H.td ""
) options
renderVoteCount (id, _, _) = do
H.td ! A.class_ "count" $ H.toHtml (show count)
where count = M.fold(\ids acc ->
if id `elem` ids then acc + 1 else acc) 0 voters
renderErrors error = do
H.p ! A.class_ "error" $ error
H.br

View file

@ -204,7 +204,7 @@ voterOptId vote = (voteOptionId (entityVal vote))
getVotersByOptionId oId =
runSqlite "noodle.db" $ do
selectList [VoteOptionId ==. (toSqlKey oId)] []
selectList [VoteOptionId ==. (toSqlKey oId)] [Asc VoteId]
deleteOptions ids = do
runSqlite "noodle.db" $ do