diff --git a/src/Handler/Profile.hs b/src/Handler/Profile.hs index 90dbdaa76..4e3fcf82e 100644 --- a/src/Handler/Profile.hs +++ b/src/Handler/Profile.hs @@ -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 diff --git a/src/Handler/Utils/Profile.hs b/src/Handler/Utils/Profile.hs index 2a5c2a1f6..647e9a7c5 100644 --- a/src/Handler/Utils/Profile.hs +++ b/src/Handler/Utils/Profile.hs @@ -40,4 +40,5 @@ data ExamOfficeSettings = ExamOfficeSettings { eosettingsGetSynced :: Bool , eosettingsGetLabels :: Bool + , eosettingsLabels :: Set ExamOfficeLabel }