From 88e123f405afd095fba7f6c8e84e2d3202faff94 Mon Sep 17 00:00:00 2001 From: SJost Date: Wed, 15 Nov 2017 16:37:19 +0100 Subject: [PATCH] Button form cleaning --- src/Handler/Home.hs | 28 ++----------------- src/Handler/Utils/Form.hs | 59 +++++---------------------------------- 2 files changed, 10 insertions(+), 77 deletions(-) diff --git a/src/Handler/Home.hs b/src/Handler/Home.hs index 6949cf94d..a5363933f 100644 --- a/src/Handler/Home.hs +++ b/src/Handler/Home.hs @@ -33,31 +33,9 @@ instance PathPiece CreateButton where -- for displaying the button only, not instance Button CreateButton where label CreateMath = [whamlet|Mathematik|] - label CreateInf = "Informatik" - + label CreateInf = "Informatik" -- END Button needed here -{- -- Old Version -getHomeR :: Handler Html -getHomeR = do - (crBtnWdgt, crBtnEnctype) <- generateFormPost $ buttonFormOld - defaultLayout $ do - setTitle "Willkommen zum ReWorX Test!" - $(widgetFile "home") - - -postHomeR :: Handler Html -postHomeR = do - ((btnResult,_), _) <- runFormPost $ buttonFormOld - $(logDebug) $ tshow btnResult - case btnResult of - (FormSuccess CreateInf) -> setMessage "Informatik anlegen" - (FormSuccess CreateMath) -> setMessage "Mathematik anlegen" - _other -> return () - getHomeR - - -} - getHomeR :: Handler Html getHomeR = do (btnWdgt, btnEnctype) <- generateFormPost (buttonForm :: Form CreateButton) @@ -70,8 +48,8 @@ postHomeR :: Handler Html postHomeR = do ((btnResult,_), _) <- runFormPost $ buttonForm case btnResult of - (FormSuccess CreateInf) -> setMessage "Informatik anlegen" - (FormSuccess CreateMath) -> setMessage "Mathematik anlegen" + (FormSuccess CreateInf) -> setMessage "Informatik-Knopf gedrückt" + (FormSuccess CreateMath) -> setMessage "Knopf Mathematik erkannt" _other -> return () getHomeR diff --git a/src/Handler/Utils/Form.hs b/src/Handler/Utils/Form.hs index f6a569e9a..798b4edfe 100644 --- a/src/Handler/Utils/Form.hs +++ b/src/Handler/Utils/Form.hs @@ -11,8 +11,6 @@ module Handler.Utils.Form where import Import -- import Data.Time -import Data.Proxy -import qualified Data.Map as Map import Handler.Utils.DateTime import Data.String (IsString(..)) @@ -24,8 +22,7 @@ import qualified Data.Text as T import Yesod.Form.Functions (parseHelper) import Yesod.Form.Bootstrap3 -import Web.PathPieces (showToPathPiece, readFromPathPiece) -import Text.Blaze (Markup) + ---------------------------- -- Buttons (new version ) -- ---------------------------- @@ -44,9 +41,9 @@ buttonField btn = Field {fieldParse, fieldView, fieldEnctype} | otherwise = return $ Left "Wrong button value" fieldParse _ _ = return $ Left "Multiple button values" - fieldView id name attrs _val _ = + fieldView fid name attrs _val _ = [whamlet| -