fix(schedule): switch to mopt

This commit is contained in:
Sarah Vaupel 2020-09-17 18:25:15 +02:00
parent 11c5aa0f10
commit 5da9a1499c

View File

@ -42,7 +42,7 @@ postScheduleR = do
scheduleOptionsForm :: Html -> MForm (HandlerFor UniWorX) (FormResult ScheduleOptions, Widget)
scheduleOptionsForm csrf = do
(viewRess, viewWidgets) <- fmap unzip . for (universeF :: [ScheduleView]) $ \sView ->
mreq (buttonField sView) ("" { fsName = Just $ toPathPiece GetScheduleView
mopt (buttonField sView) ("" { fsName = Just $ toPathPiece GetScheduleView
, fsAttrs = if sView == currentScheduleView then [("disabled","")] else mempty
}) Nothing
viewRes <- if
@ -51,7 +51,7 @@ postScheduleR = do
$logInfoS "SCHEDULE-VIEW" $ "encountered error(s): " <> tshow errs
(return . FormFailure . mconcat . catMaybes . (fmap $ preview _FormFailure) . toNullable) errs
| otherwise -> case catMaybes (formResultToMaybe <$> viewRess) of -- TODO: rethink this case
[sView] -> do
[Just sView] -> do
$logInfoS "SCHEDULE-VIEW" $ "encountered single view result: " <> tshow sView <> ", all results: " <> tshow viewRess
return $ FormSuccess sView
_ -> do
@ -64,7 +64,7 @@ postScheduleR = do
_ -> mempty
(offsetRess, offsetWidgets) <- fmap unzip . for offsetBtns $ \btn ->
mreq (buttonField btn) ("" { fsName = Just $ toPathPiece GetScheduleOffset
mopt (buttonField btn) ("" { fsName = Just $ toPathPiece GetScheduleOffset
, fsAttrs = if offsetFromWeekBtn btn == currentScheduleOffset then [("disabled","")] else mempty
}) Nothing
@ -74,7 +74,7 @@ postScheduleR = do
$logInfoS "SCHEDULE-OFFSET" $ "encountered error(s): " <> tshow errs
(return . FormFailure . mconcat . catMaybes . (fmap $ preview _FormFailure) . toNullable) errs
| otherwise -> case catMaybes (formResultToMaybe <$> offsetRess) of -- TODO: rethink this case
[offset] -> do
[Just offset] -> do
$logInfoS "SCHEDULE-OFFSET" $ "encountered single offset result: " <> tshow offset <> ", all results: " <> tshow offsetRess
(return . FormSuccess . addOffset currentScheduleOffset . schedBtnOffset) offset
_ -> do