chore(avs): preparations for avs synch confirmation
This commit is contained in:
parent
eb4e50b19c
commit
cabecec99d
@ -100,7 +100,6 @@ validateAvsQueryStatus = do
|
|||||||
AvsQueryStatus ids <- State.get
|
AvsQueryStatus ids <- State.get
|
||||||
guardValidation (MsgAvsQueryStatusInvalid $ tshow ids) $ not (null ids)
|
guardValidation (MsgAvsQueryStatusInvalid $ tshow ids) $ not (null ids)
|
||||||
|
|
||||||
|
|
||||||
avsLicenceOptions :: OptionList AvsLicence
|
avsLicenceOptions :: OptionList AvsLicence
|
||||||
avsLicenceOptions = mkOptionList
|
avsLicenceOptions = mkOptionList
|
||||||
[ Option
|
[ Option
|
||||||
|
|||||||
@ -214,6 +214,9 @@ postAdminTestR = do
|
|||||||
testHamlet1 <- withUrlRenderer $(hamletFile "templates/i18n/test/en-eu.hamlet")
|
testHamlet1 <- withUrlRenderer $(hamletFile "templates/i18n/test/en-eu.hamlet")
|
||||||
--let testHamlet2 = $(i18nHamletFile "test")
|
--let testHamlet2 = $(i18nHamletFile "test")
|
||||||
let testHamlet2 = testHamlet1
|
let testHamlet2 = testHamlet1
|
||||||
|
btnModalText = [whamlet|<button type="button" class=#{unwords $ map toPathPiece [BCIsButton, BCDanger]}>
|
||||||
|
Button-Modal
|
||||||
|
|]
|
||||||
|
|
||||||
let locallyDefinedPageHeading = [whamlet|Admin TestPage for Uni2work|]
|
let locallyDefinedPageHeading = [whamlet|Admin TestPage for Uni2work|]
|
||||||
siteLayout locallyDefinedPageHeading $ do
|
siteLayout locallyDefinedPageHeading $ do
|
||||||
|
|||||||
@ -596,7 +596,6 @@ postLmsR sid qsh = do
|
|||||||
when (diffSelected /= 0) $ addMessageI Warning $ MsgLmsActionFailed diffSelected
|
when (diffSelected /= 0) $ addMessageI Warning $ MsgLmsActionFailed diffSelected
|
||||||
redirect currentRoute
|
redirect currentRoute
|
||||||
|
|
||||||
|
|
||||||
let heading = citext2widget $ qualificationName quali
|
let heading = citext2widget $ qualificationName quali
|
||||||
siteLayout heading $ do
|
siteLayout heading $ do
|
||||||
setTitle $ toHtml $ unSchoolKey sid <> "-" <> qsh
|
setTitle $ toHtml $ unSchoolKey sid <> "-" <> qsh
|
||||||
|
|||||||
@ -303,6 +303,7 @@ data FormIdentifier
|
|||||||
| FIDAvsQueryLicenceDiffs
|
| FIDAvsQueryLicenceDiffs
|
||||||
| FIDAvsQueryLicence
|
| FIDAvsQueryLicence
|
||||||
| FIDAvsSetLicence
|
| FIDAvsSetLicence
|
||||||
|
| FIDAvsRemoveLicences
|
||||||
| FIDLmsLetter
|
| FIDLmsLetter
|
||||||
| FIDAbsUnknownLicences
|
| FIDAbsUnknownLicences
|
||||||
deriving (Eq, Ord, Read, Show)
|
deriving (Eq, Ord, Read, Show)
|
||||||
@ -570,9 +571,9 @@ runButtonFormHash (hash -> hVal) fid = do
|
|||||||
hForm = aopt hiddenField "" $ Just $ Just hVal
|
hForm = aopt hiddenField "" $ Just $ Just hVal
|
||||||
((btnResult, btnWdgt), btnEnctype) <- runFormPost $ identifyForm fid $ \html ->
|
((btnResult, btnWdgt), btnEnctype) <- runFormPost $ identifyForm fid $ \html ->
|
||||||
flip (renderAForm FormStandard) html $ (,) <$> bForm <*> hForm
|
flip (renderAForm FormStandard) html $ (,) <$> bForm <*> hForm
|
||||||
let btnForm = wrapForm btnWdgt def { formAction = SomeRoute <$> currentRoute
|
let btnForm = wrapForm btnWdgt def { formAction = SomeRoute <$> currentRoute
|
||||||
, formEncoding = btnEnctype
|
, formEncoding = btnEnctype
|
||||||
, formSubmit = FormNoSubmit
|
, formSubmit = FormNoSubmit
|
||||||
}
|
}
|
||||||
res <- formResultMaybe btnResult $ \case
|
res <- formResultMaybe btnResult $ \case
|
||||||
(btn, Just rVal) | hVal == rVal -> return $ Just btn -- hash value from hidden field must be present and matching
|
(btn, Just rVal) | hVal == rVal -> return $ Just btn -- hash value from hidden field must be present and matching
|
||||||
@ -582,6 +583,27 @@ runButtonFormHash (hash -> hVal) fid = do
|
|||||||
return Nothing
|
return Nothing
|
||||||
return (btnForm, res)
|
return (btnForm, res)
|
||||||
|
|
||||||
|
-- | like runButtonFormHash, but showing only a given list of buttons, especially for buttons that are not in the Finite typeclass.
|
||||||
|
runButtonFormHash' :: ( PathPiece ident, Eq ident, RenderAFormSite site
|
||||||
|
, Button site ButtonSubmit, Button site a, Hashable h)
|
||||||
|
=> h -> [a] -> ident -> HandlerT site IO (WidgetT site IO (), Maybe a)
|
||||||
|
runButtonFormHash' (hash -> hVal) btns fid = do
|
||||||
|
currentRoute <- getCurrentRoute
|
||||||
|
let bForm = disambiguateButtons $ combinedButtonField btns ""
|
||||||
|
hForm = aopt hiddenField "" $ Just $ Just hVal
|
||||||
|
((btnResult, btnWdgt), btnEnctype) <- runFormPost $ identifyForm fid $ \html ->
|
||||||
|
flip (renderAForm FormStandard) html $ (,) <$> bForm <*> hForm
|
||||||
|
let btnForm = wrapForm btnWdgt def { formAction = SomeRoute <$> currentRoute
|
||||||
|
, formEncoding = btnEnctype
|
||||||
|
, formSubmit = FormNoSubmit
|
||||||
|
}
|
||||||
|
res <- formResultMaybe btnResult $ \case
|
||||||
|
(btn, Just rVal) | hVal == rVal -> return $ Just btn -- hash value from hidden field must be present and matching
|
||||||
|
_ -> do
|
||||||
|
addMessageI Error MsgBtnFormOutdated
|
||||||
|
whenIsJust currentRoute redirect -- redirect is needed to reset hidden-field value
|
||||||
|
return Nothing
|
||||||
|
return (btnForm, res)
|
||||||
|
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
module Utils.Frontend.Modal
|
module Utils.Frontend.Modal
|
||||||
( Modal(..)
|
( Modal(..)
|
||||||
, customModal
|
, customModal
|
||||||
, modal, msgModal
|
, modal, btnModal, msgModal
|
||||||
, addMessageModal
|
, addMessageModal
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -14,6 +14,7 @@ import ClassyPrelude.Yesod
|
|||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Utils.Route
|
import Utils.Route
|
||||||
import Utils.Message
|
import Utils.Message
|
||||||
|
import Utils.Form (ButtonClass())
|
||||||
|
|
||||||
import Settings (widgetFile)
|
import Settings (widgetFile)
|
||||||
|
|
||||||
@ -47,6 +48,17 @@ modal modalTrigger' modalContent = customModal Modal{..}
|
|||||||
modalId = Nothing
|
modalId = Nothing
|
||||||
modalTrigger mRoute triggerId = $(widgetFile "widgets/modal/trigger")
|
modalTrigger mRoute triggerId = $(widgetFile "widgets/modal/trigger")
|
||||||
|
|
||||||
|
-- | Variant of `modal` that looks like a button
|
||||||
|
btnModal :: (PathPiece (ButtonClass site))
|
||||||
|
=> Text -- ^ Button Text
|
||||||
|
-> [ButtonClass site] -- ^ Button class
|
||||||
|
-> Either (SomeRoute site) (WidgetFor site ()) -- ^ Modal contant: either dynamic link or static widget
|
||||||
|
-> WidgetFor site () -- ^ result widget
|
||||||
|
btnModal btl bcs = modal fakeBtn
|
||||||
|
where
|
||||||
|
fakeBtn = [whamlet|<button :not (onull bcs):class=#{unwords $ map toPathPiece bcs}>
|
||||||
|
#{btl}
|
||||||
|
|]
|
||||||
|
|
||||||
-- | Variant of `modal` for use in messages (uses a different id generator to avoid collisions)
|
-- | Variant of `modal` for use in messages (uses a different id generator to avoid collisions)
|
||||||
msgModal :: WidgetFor site ()
|
msgModal :: WidgetFor site ()
|
||||||
|
|||||||
@ -69,6 +69,11 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later
|
|||||||
<li>^{modal "Klick mich für Ajax-Test" (Left $ SomeRoute UsersR)}
|
<li>^{modal "Klick mich für Ajax-Test" (Left $ SomeRoute UsersR)}
|
||||||
<li>^{modal "Klick mich für Content-Test" (Right "Test Inhalt für Modal")}
|
<li>^{modal "Klick mich für Content-Test" (Right "Test Inhalt für Modal")}
|
||||||
<li>^{modal "Email-Test" (Right emailWidget')}
|
<li>^{modal "Email-Test" (Right emailWidget')}
|
||||||
|
<li>
|
||||||
|
Modal as button
|
||||||
|
<ul>
|
||||||
|
<li>^{modal btnModalText (Right "Noch ein Test-Inhalt für ein Button Modal")}
|
||||||
|
<li>^{btnModal "Another Button" [BCIsButton, BCDanger] (Right "anderer Text")}
|
||||||
<li>
|
<li>
|
||||||
Some icons: ^{isVisible False} ^{hasComment True}
|
Some icons: ^{isVisible False} ^{hasComment True}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user