Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

IT COMPILES

  • Loading branch information...
commit 4daa0a25a9f44c69cbdc5c0bb4e8aa4f6433de45 1 parent 9b60a74
geoff golder authored
15 .ghci.back
View
@@ -0,0 +1,15 @@
+:set -i.:config:dist/build/autogen
+:set -XCPP
+:set -XTemplateHaskell
+:set -XQuasiQuotes
+:set -XOverloadedStrings
+:set -XNoImplicitPrelude
+:set -XOverloadedStrings
+:set -XMultiParamTypeClasses
+:set -XTypeFamilies
+:set -XGADTs
+:set -XGeneralizedNewtypeDeriving
+:set -XFlexibleContexts
+:set -XFlexibleInstances
+:set -XTypeSynonymInstances
+:set -XEmptyDataDecls
1  Application.hs
View
@@ -26,6 +26,7 @@ import Handler.Root
import Handler.Player
import Handler.Table
import Handler.GamingSession
+import Helpers.Model
-- This line actually creates our YesodSite instance. It is the second half
1  Exodus.cabal
View
@@ -95,7 +95,6 @@ executable Exodus
, time
, old-locale
, containers
- , safe
, hamlet >= 0.10 && < 0.11
, shakespeare-css >= 0.10 && < 0.11
, shakespeare-js >= 0.11 && < 0.12
20 Handler/Table.hs
View
@@ -1,8 +1,7 @@
{-# LANGUAGE TypeSynonymInstances, OverloadedStrings #-}
module Handler.Table
( getTablesR
- , postTablesR
- , getTableR
+ , postTablesR , getTableR
, tableCheckinWidget
)
where
@@ -15,6 +14,8 @@ import qualified Data.Text.Lazy as TL
import Text.Julius
import qualified Data.Text as T hiding (null)
import Data.Maybe
+import Database.Persist.Store
+import qualified Data.Text as T
tableForm :: Form Table
tableForm = renderDivs $ Table
@@ -73,15 +74,24 @@ addIdent (Entity tableId table) = do
tableClickHandlerWidget :: String -> TableId -> PlayerId -> Maybe Int -> Widget
tableClickHandlerWidget elemId tid playerId seatId = do
+ let seatNumber = if seatId == Nothing
+ then "null"
+ else show $ fromJust seatId
+ let pid = fromPersistToJS $ unKey playerId
toWidget[julius|
$(function() {
$('#{show elemId}').click.post(
'@{GamingSessionsR}',
- { player: #{show playerId}, table: #{show tid}, seat:#{show (fromJust seatId)} },
+ { player: '#{pid}', table: '#{show tid}', seat:'#{seatNumber}' },
);
});
|]
+ toWidget[hamlet|something<br/>|]
-
-
+fromPersistToJS :: PersistValue -> String
+fromPersistToJS p = do
+ let (a) = fromPersistValue p
+ case a of
+ Left l -> T.unpack l
+ Right r -> r
2  templates/tableCheckinWidget.hamlet
View
@@ -4,5 +4,5 @@ $if null tableTuple
$else
<ul .checkin-widget>
$forall (id, tid, table) <- tableTuple
- <li ##{T.unpack id} .table>{tableName table}
+ <li ##{T.unpack id} .table>#{tableName table}
^{tableClickHandlerWidget (T.unpack id) tid playerId Nothing}
Please sign in to comment.
Something went wrong with that request. Please try again.