{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE FlexibleContexts #-} module Handler.Home where import Import import Handler.Utils import Data.Time import qualified Data.Text as T import Yesod.Form.Bootstrap3 import Web.PathPieces (showToPathPiece, readFromPathPiece) import Colonnade import Yesod.Colonnade import qualified Data.UUID.Cryptographic as UUID -- BEGIN - Buttons needed only here data CreateButton = CreateMath | CreateInf -- Dummy for Example deriving (Enum, Eq, Ord, Bounded, Read, Show) instance PathPiece CreateButton where -- for displaying the button only, not really for paths toPathPiece = showToPathPiece fromPathPiece = readFromPathPiece instance Button CreateButton where label CreateMath = [whamlet|Mathematik|] label CreateInf = "Informatik" -- END Button needed here getHomeR :: Handler Html getHomeR = do (crBtnWdgt, crBtnEnctype) <- generateFormPost $ buttonForm defaultLayout $ do setTitle "Willkommen zum ReWorX Test!" $(widgetFile "home") postHomeR :: Handler Html postHomeR = do ((btnResult,_), _) <- runFormPost $ buttonForm $(logDebug) $ tshow btnResult case btnResult of (FormSuccess CreateInf) -> setMessage "Informatik anlegen" (FormSuccess CreateMath) -> setMessage "Mathematik anlegen" _other -> return () getHomeR