From e4f37a1bcc3666791ab3df91cadc3f85a6d16874 Mon Sep 17 00:00:00 2001 From: SJost Date: Sat, 16 Feb 2019 17:04:13 +0100 Subject: [PATCH] templates/widgets/form-section-title.shamlet created for @hamannf --- src/Handler/Utils/Form.hs | 23 +++++++++++--------- templates/widgets/form-section-title.shamlet | 2 ++ 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 templates/widgets/form-section-title.shamlet diff --git a/src/Handler/Utils/Form.hs b/src/Handler/Utils/Form.hs index bb434e935..4e0102360 100644 --- a/src/Handler/Utils/Form.hs +++ b/src/Handler/Utils/Form.hs @@ -39,7 +39,8 @@ import Control.Monad.Writer.Class import Data.Scientific (Scientific) import Data.Ratio import Text.Read (readMaybe) -import Text.Blaze (ToMarkup,preEscapedText) +import Text.Blaze (ToMarkup) +import Text.Hamlet (shamletFile) import Utils.Lens @@ -640,19 +641,21 @@ infoField txt = Field { fieldEnctype = UrlEncoded , fieldView = \_theId _name _attrs _val _isReq -> [whamlet|#{txt}|] } -aformSection :: (Monad m) => Text -> AForm m () -aformSection = formToAForm . formSection +aformSection :: (Monad m, ToMarkup t) => t -> AForm m () +aformSection = formToAForm . fmap (second pure) . formSection -formSection :: (Monad m) => Text -> MForm m (FormResult (), [FieldView site]) -- TODO: WIP, delete -formSection infoText = return (FormSuccess (), [infoView]) +formSection :: (Monad m, ToMarkup t) => t -> MForm m (FormResult (), FieldView site) -- TODO: WIP, delete +formSection formSectionTitle = return (FormSuccess (), infoView) where + flabel :: Html + flabel = $(shamletFile "./templates/widgets/form-section-title.shamlet") -- TODO: Why must this be fully qualified? infoView = FieldView - { fvLabel = preEscapedText $ "

" <> infoText <> "

" - , fvTooltip = Nothing - , fvId = "formSection" - , fvErrors = Nothing + { fvLabel = flabel + , fvTooltip = Nothing + , fvId = "formSection" + , fvErrors = Nothing , fvRequired = False - , fvInput = mempty -- [whamlet|

#{infoText}|] + , fvInput = mempty } infoForm :: Text -> Form () -- TODO: WIP, delete diff --git a/templates/widgets/form-section-title.shamlet b/templates/widgets/form-section-title.shamlet new file mode 100644 index 000000000..0f29e1b26 --- /dev/null +++ b/templates/widgets/form-section-title.shamlet @@ -0,0 +1,2 @@ +

+ #{formSectionTitle} \ No newline at end of file