From b35946859309fbb526043194c8620c5fc0844809 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 25 Sep 2020 12:02:59 +0200 Subject: [PATCH] feat(allocations): show staff descriptions --- src/Handler/Course/Edit.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Handler/Course/Edit.hs b/src/Handler/Course/Edit.hs index 09e032bbb..a4ed224a0 100644 --- a/src/Handler/Course/Edit.hs +++ b/src/Handler/Course/Edit.hs @@ -243,6 +243,15 @@ makeCourseForm miButtonAction template = identifyForm FIDcourse . validateFormDB allocationOptions <- mkOptionList <$> mapM mkAllocationOption (availableAllocations ++ activeAllocations) let + explainedAllocationOptions = return allocationOptions `explainOptionList` \allocId -> hoistMaybe . listToMaybe $ do + (Entity allocId' Allocation{..}, _) <- availableAllocations' + guard $ allocId' == allocId + toWidget <$> hoistMaybe allocationStaffDescription + + doExplain = has (folded . _entityVal . _allocationStaffDescription . _Just) $ availableAllocations ++ activeAllocations + allocField | doExplain = explainedSelectionField Nothing explainedAllocationOptions + | otherwise = selectField' Nothing $ return allocationOptions + userAdmin = not $ null adminSchools mayChange = Just False /= fmap (|| userAdmin) currentAllocationAvailable @@ -254,7 +263,7 @@ makeCourseForm miButtonAction template = identifyForm FIDcourse . validateFormDB | otherwise = aforcedJust in AllocationCourseForm - <$> ainp (selectField' Nothing $ return allocationOptions) (fslI MsgCourseAllocation) (fmap acfAllocation $ template >>= cfAllocation) + <$> ainp allocField (fslI MsgCourseAllocation) (fmap acfAllocation $ template >>= cfAllocation) <*> ainp (natFieldI MsgCourseAllocationMinCapacityMustBeNonNegative) (fslI MsgCourseAllocationMinCapacity & setTooltip MsgCourseAllocationMinCapacityTip) (fmap acfMinCapacity $ template >>= cfAllocation) <*> apopt checkBoxField (fslI MsgCourseDeregisterNoShow & setTooltip MsgCourseDeregisterNoShowTip) ((<|> Just True) . fmap acfDeregisterNoShow $ template >>= cfAllocation)