refactor(exams): restruct case wrt. aformSection

This commit is contained in:
Sarah Vaupel 2021-06-19 10:05:03 +02:00 committed by Gregor Kleen
parent 4109db6f81
commit 5c813ed02b

View File

@ -160,14 +160,15 @@ examForm (Entity _ Course{..}) template csrf = hoist liftHandler $ do
(maybe mempty (authorshipStatementDefinitionContent . entityVal) mSchoolAuthorshipStatement)
contentField ttipReq = bool forcedContentField (reqContentField ttipReq) schoolSheetExamAuthorshipStatementAllowOther
in case schoolSheetExamAuthorshipStatementMode of
SchoolAuthorshipStatementModeNone -> pure Nothing
SchoolAuthorshipStatementModeOptional -> aformSection MsgExamAuthorshipStatementSection
*> optionalActionA
(contentField id)
(fslI MsgExamAuthorshipStatementRequired & setTooltip MsgExamAuthorshipStatementRequiredTip)
((is _Just . efAuthorshipStatement <$> template) <|> (pure $ is _Just schoolSheetExamAuthorshipStatementDefinition))
SchoolAuthorshipStatementModeRequired -> aformSection MsgExamAuthorshipStatementSection
*> (fmap Just $ contentField (setTooltip MsgExamAuthorshipStatementRequiredDisabledOnTip))
SchoolAuthorshipStatementModeNone -> pure Nothing -- suppress display of whole section incl. header
otherMode -> aformSection MsgExamAuthorshipStatementSection
*> case otherMode of
SchoolAuthorshipStatementModeOptional -> optionalActionA
(contentField id)
(fslI MsgExamAuthorshipStatementRequired & setTooltip MsgExamAuthorshipStatementRequiredTip)
((is _Just . efAuthorshipStatement <$> template) <|> (pure $ is _Just schoolSheetExamAuthorshipStatementDefinition))
SchoolAuthorshipStatementModeRequired -> fmap Just . contentField $ setTooltip MsgExamAuthorshipStatementRequiredDisabledOnTip
_none -> pure Nothing
officeSchoolsForm :: Maybe (Set SchoolId) -> AForm Handler (Set SchoolId)
officeSchoolsForm mPrev = wFormToAForm $ do