Cleanup buttonForm & remove duplicate identifyForm calls

This commit is contained in:
Gregor Kleen 2019-03-28 12:06:50 +01:00
parent 4dbeff18c0
commit 68a0f7c566
4 changed files with 17 additions and 20 deletions

View File

@ -216,7 +216,7 @@ postAdminUserR uuid = do
let heading =
[whamlet|_{MsgAccessRightsFor} ^{nameWidget userDisplayName userSurname}|]
-- Delete Button needed in data-delete
(btnWgt, btnEnctype) <- generateFormPost (buttonForm :: Form ButtonDelete)
(btnWgt, btnEnctype) <- generateFormPost (identifyForm FIDUserDelete $ buttonForm :: Form ButtonDelete)
let btnForm = wrapForm btnWgt def
{ formAction = Just $ SomeRoute $ AdminUserDeleteR uuid
, formEncoding = btnEnctype
@ -231,7 +231,7 @@ postAdminUserR uuid = do
postAdminUserDeleteR :: CryptoUUIDUser -> Handler Html
postAdminUserDeleteR uuid = do
uid <- decrypt uuid
((btnResult,_), _) <- runFormPost (buttonForm :: Form ButtonDelete)
((btnResult,_), _) <- runFormPost (identifyForm FIDUserDelete $ buttonForm :: Form ButtonDelete)
case btnResult of
(FormSuccess BtnDelete) -> do
User{..} <- runDB $ get404 uid

View File

@ -138,20 +138,6 @@ linkButton lbl cls url = do
|]
-- buttonForm :: (Button UniWorX a, Finite a) => Markup -> MForm (HandlerT UniWorX IO) (FormResult a, Widget)
buttonForm :: (Button UniWorX a, Finite a) => Form a
buttonForm = identifyForm FIDbuttonForm buttonFormAux -- TODO: distinguish diffent buttons despite @disambiguateButtons@
where
buttonFormAux csrf = do
(res, ($ []) -> fViews) <- aFormToForm . disambiguateButtons $ combinedButtonFieldF ""
return (res, [whamlet|
$newline never
#{csrf}
$forall bView <- fViews
^{fvInput bView}
|])
------------
-- Fields --
------------

View File

@ -179,8 +179,8 @@ data FormIdentifier
| FIDCourseRegister
| FIDuserRights
| FIDcUserNote
| FIDbuttonForm
| FIDAdminDemo
| FIDUserDelete
deriving (Eq, Ord, Read, Show)
instance PathPiece FormIdentifier where
@ -347,6 +347,17 @@ submitButtonView = do
fieldView bField btnId "" mempty (Right BtnSubmit) False
buttonForm :: (Button site a, Finite a) => Html -> MForm (HandlerT site IO) (FormResult a, WidgetT site IO ())
buttonForm csrf = do
(res, ($ []) -> fViews) <- aFormToForm . disambiguateButtons $ combinedButtonFieldF ""
return (res, [whamlet|
$newline never
#{csrf}
$forall bView <- fViews
^{fvInput bView}
|])
-------------------
-- Custom Fields --
-------------------

View File

@ -535,10 +535,10 @@ section {
margin-top: 20px;
padding-top: 20px;
}
}
section:last-of-type {
border-bottom: none;
&:last-of-type {
border-bottom: none;
}
}
.pseudonym {