PostButton Helpers added to HomeR
This commit is contained in:
parent
a11c542d64
commit
70ad7474fe
2
routes
2
routes
@ -4,7 +4,7 @@
|
||||
/favicon.ico FaviconR GET
|
||||
/robots.txt RobotsR GET
|
||||
|
||||
/ HomeR GET
|
||||
/ HomeR GET POST
|
||||
/profile ProfileR GET
|
||||
|
||||
|
||||
|
||||
@ -24,5 +24,23 @@ import qualified Data.UUID.Cryptographic as UUID
|
||||
|
||||
getHomeR :: Handler Html
|
||||
getHomeR = defaultLayout $ do
|
||||
(crInfWdgt, crInfEnctype) <- generateFormPost $ postButtonForm "Informatik"
|
||||
(crMatWdgt, crMatEnctype) <- generateFormPost $ postButtonForm "Mathematik"
|
||||
setTitle "Willkommen zum ReWorX Test!"
|
||||
$(widgetFile "home")
|
||||
|
||||
|
||||
postHomeR :: Handler Html
|
||||
postHomeR = do
|
||||
((infResult,_), _) <- runFormPost $ postButtonForm "Informatik"
|
||||
((matResult,_), _) <- runFormPost $ postButtonForm "Mathematik"
|
||||
setMessage "ButtonTest"
|
||||
case infResult of
|
||||
(FormSuccess ()) -> setMessage "Informatik anlegen" -- does not work somehow
|
||||
-- TODO runDB
|
||||
_other -> return ()
|
||||
case matResult of
|
||||
(FormSuccess ()) -> setMessage "Mathematik anlegen"
|
||||
-- TODO runDB
|
||||
_other -> return ()
|
||||
getHomeR
|
||||
|
||||
@ -17,8 +17,12 @@ import Data.String (IsString(..))
|
||||
import qualified Data.Text as T
|
||||
-- import Yesod.Form.Types
|
||||
import Yesod.Form.Functions (parseHelper)
|
||||
import Yesod.Form.Bootstrap3
|
||||
|
||||
|
||||
-------------
|
||||
-- Buttons --
|
||||
-------------
|
||||
|
||||
formBtnSave :: (Text,Text,Text)
|
||||
formBtnSave = ("save" ,"Speichern" ,"btn-primary")
|
||||
@ -44,6 +48,16 @@ defaultFormActions = [ formBtnDelete
|
||||
, formBtnSave
|
||||
]
|
||||
|
||||
-- Post-Buttons
|
||||
-- postButtonForm :: MonadHandler m =>
|
||||
-- Text -> Text.Blaze.Internal.Markup -> MForm m (FormResult (), WidgetT (HandlerSite m) IO ())
|
||||
postButtonForm lblId = identifyForm lblId buttonF
|
||||
where
|
||||
buttonF = renderBootstrap3 BootstrapInlineForm $ pure () <* bootstrapSubmit bProps
|
||||
bProps :: BootstrapSubmit Text
|
||||
bProps = fromString $ unpack lblId
|
||||
|
||||
|
||||
------------
|
||||
-- Fields --
|
||||
------------
|
||||
|
||||
@ -58,3 +58,19 @@
|
||||
<li .list-group-item>
|
||||
<a href=@{CourseEditR}>Kurse anlegen
|
||||
editieren und anzeigen
|
||||
|
||||
<h2 #design>Funktionen zum Testen
|
||||
|
||||
<ul .list-group>
|
||||
|
||||
<li .list-group-item>
|
||||
Institut einmalig in Datenbank einfügen:
|
||||
<form .form-inline method=post action=@{HomeR} enctype=#{crInfEnctype}>
|
||||
^{crInfWdgt}
|
||||
<form .form-inline method=post action=@{HomeR} enctype=#{crMatEnctype}>
|
||||
^{crMatWdgt}
|
||||
|
||||
<li .list-group-item>
|
||||
<a href=@{CourseEditR}>Kurse anlegen
|
||||
editieren und anzeigen
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user