chore(profile): add profile form stub for eo-labels

This commit is contained in:
Sarah Vaupel 2021-12-02 16:19:28 +01:00
parent 7611011794
commit ca1081c996
2 changed files with 14 additions and 7 deletions

View File

@ -316,14 +316,17 @@ examOfficeForm :: Maybe ExamOfficeSettings -> AForm Handler ExamOfficeSettings
examOfficeForm template = wFormToAForm $ do
(_uid, User{userExamOfficeGetSynced,userExamOfficeGetLabels}) <- requireAuthPair
userIsExamOffice <- liftHandler . hasReadAccessTo $ ExamOfficeR EOExamsR
userExamOfficeLabels <- return $ maybe Set.empty eosettingsLabels template
let
eoLabelForm :: AForm Handler (Set ExamOfficeLabel)
eoLabelForm = pure userExamOfficeLabels -- TODO
if userIsExamOffice
then aFormToWForm $ liftA2 ExamOfficeSettings
( aformSection MsgFormExamOffice
*> apopt checkBoxField (fslI MsgExamOfficeGetSynced & setTooltip MsgExamOfficeGetSyncedTip) (eosettingsGetSynced <$> template)
)
( apopt checkBoxField (fslI MsgExamOfficeGetLabels & setTooltip MsgExamOfficeGetLabelsTip) (eosettingsGetLabels <$> template)
)
else return . pure . fromMaybe (ExamOfficeSettings userExamOfficeGetSynced userExamOfficeGetLabels) $ template
then aFormToWForm $ ExamOfficeSettings
<$ aformSection MsgFormExamOffice
<*> apopt checkBoxField (fslI MsgExamOfficeGetSynced & setTooltip MsgExamOfficeGetSyncedTip) (eosettingsGetSynced <$> template)
<*> apopt checkBoxField (fslI MsgExamOfficeGetLabels & setTooltip MsgExamOfficeGetLabelsTip) (eosettingsGetLabels <$> template)
<*> eoLabelForm
else return . pure . fromMaybe (ExamOfficeSettings userExamOfficeGetSynced userExamOfficeGetLabels userExamOfficeLabels) $ template
validateSettings :: User -> FormValidator SettingsForm Handler ()
@ -363,6 +366,7 @@ postProfileR = do
E.&&. userSchool E.^. UserSchoolUser E.==. E.val uid
E.&&. userSchool E.^. UserSchoolSchool E.==. school E.^. SchoolId
return $ school E.^. SchoolId
userExamOfficeLabels <- return Set.empty -- TODO
allocs <- runDB $ getAllocationNotifications uid
let settingsTemplate = Just SettingsForm
{ stgDisplayName = userDisplayName
@ -381,6 +385,7 @@ postProfileR = do
, stgExamOfficeSettings = ExamOfficeSettings
{ eosettingsGetSynced = userExamOfficeGetSynced
, eosettingsGetLabels = userExamOfficeGetLabels
, eosettingsLabels = userExamOfficeLabels
}
, stgAllocationNotificationSettings = allocs
}
@ -401,6 +406,7 @@ postProfileR = do
, UserNotificationSettings =. stgNotificationSettings
, UserShowSex =. stgShowSex
, UserExamOfficeGetSynced =. (stgExamOfficeSettings & eosettingsGetSynced)
, UserExamOfficeGetLabels =. (stgExamOfficeSettings & eosettingsGetLabels)
] ++ [ UserDisplayEmail =. stgDisplayEmail | userDisplayEmail == stgDisplayEmail ]
setAllocationNotifications uid stgAllocationNotificationSettings
updateFavourites Nothing

View File

@ -40,4 +40,5 @@ data ExamOfficeSettings
= ExamOfficeSettings
{ eosettingsGetSynced :: Bool
, eosettingsGetLabels :: Bool
, eosettingsLabels :: Set ExamOfficeLabel
}