Skip to content

Commit

Permalink
IT COMPILES
Browse files Browse the repository at this point in the history
  • Loading branch information
gdoteof committed Mar 23, 2012
1 parent 9b60a74 commit 4daa0a2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
15 changes: 15 additions & 0 deletions .ghci.back
@@ -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 change: 1 addition & 0 deletions Application.hs
Expand Up @@ -26,6 +26,7 @@ import Handler.Root
import Handler.Player import Handler.Player
import Handler.Table import Handler.Table
import Handler.GamingSession import Handler.GamingSession
import Helpers.Model




-- This line actually creates our YesodSite instance. It is the second half -- This line actually creates our YesodSite instance. It is the second half
Expand Down
1 change: 0 additions & 1 deletion Exodus.cabal
Expand Up @@ -95,7 +95,6 @@ executable Exodus
, time , time
, old-locale , old-locale
, containers , containers
, safe
, hamlet >= 0.10 && < 0.11 , hamlet >= 0.10 && < 0.11
, shakespeare-css >= 0.10 && < 0.11 , shakespeare-css >= 0.10 && < 0.11
, shakespeare-js >= 0.11 && < 0.12 , shakespeare-js >= 0.11 && < 0.12
Expand Down
20 changes: 15 additions & 5 deletions Handler/Table.hs
@@ -1,8 +1,7 @@
{-# LANGUAGE TypeSynonymInstances, OverloadedStrings #-} {-# LANGUAGE TypeSynonymInstances, OverloadedStrings #-}
module Handler.Table module Handler.Table
( getTablesR ( getTablesR
, postTablesR , postTablesR , getTableR
, getTableR
, tableCheckinWidget , tableCheckinWidget
) )
where where
Expand All @@ -15,6 +14,8 @@ import qualified Data.Text.Lazy as TL
import Text.Julius import Text.Julius
import qualified Data.Text as T hiding (null) import qualified Data.Text as T hiding (null)
import Data.Maybe import Data.Maybe
import Database.Persist.Store
import qualified Data.Text as T


tableForm :: Form Table tableForm :: Form Table
tableForm = renderDivs $ Table tableForm = renderDivs $ Table
Expand Down Expand Up @@ -73,15 +74,24 @@ addIdent (Entity tableId table) = do


tableClickHandlerWidget :: String -> TableId -> PlayerId -> Maybe Int -> Widget tableClickHandlerWidget :: String -> TableId -> PlayerId -> Maybe Int -> Widget
tableClickHandlerWidget elemId tid playerId seatId = do tableClickHandlerWidget elemId tid playerId seatId = do
let seatNumber = if seatId == Nothing
then "null"
else show $ fromJust seatId
let pid = fromPersistToJS $ unKey playerId
toWidget[julius| toWidget[julius|
$(function() { $(function() {
$('#{show elemId}').click.post( $('#{show elemId}').click.post(
'@{GamingSessionsR}', '@{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 changes: 1 addition & 1 deletion templates/tableCheckinWidget.hamlet
Expand Up @@ -4,5 +4,5 @@ $if null tableTuple
$else $else
<ul .checkin-widget> <ul .checkin-widget>
$forall (id, tid, table) <- tableTuple $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} ^{tableClickHandlerWidget (T.unpack id) tid playerId Nothing}

0 comments on commit 4daa0a2

Please sign in to comment.