chore: disable accept button for failing results
This commit is contained in:
parent
02589e4d00
commit
f9b545952d
@ -26,6 +26,7 @@ makeLenses_ ''ExamAutoOccurrenceCalculateForm
|
|||||||
data ExamAutoOccurrenceAcceptForm = ExamAutoOccurrenceAcceptForm
|
data ExamAutoOccurrenceAcceptForm = ExamAutoOccurrenceAcceptForm
|
||||||
{ eaofMapping :: ExamOccurrenceMapping ExamOccurrenceId
|
{ eaofMapping :: ExamOccurrenceMapping ExamOccurrenceId
|
||||||
, eaofAssignment :: Map UserId (Maybe ExamOccurrenceId)
|
, eaofAssignment :: Map UserId (Maybe ExamOccurrenceId)
|
||||||
|
, eaofSuccess :: Bool
|
||||||
} deriving (Eq, Ord, Read, Show, Generic, Typeable)
|
} deriving (Eq, Ord, Read, Show, Generic, Typeable)
|
||||||
|
|
||||||
deriveJSON defaultOptions
|
deriveJSON defaultOptions
|
||||||
@ -153,7 +154,9 @@ examAutoOccurrenceIgnoreRoomsForm occId calculateRes protoForm html = do
|
|||||||
examAutoOccurrenceAcceptForm :: Maybe ExamAutoOccurrenceAcceptForm -> Form ExamAutoOccurrenceAcceptForm
|
examAutoOccurrenceAcceptForm :: Maybe ExamAutoOccurrenceAcceptForm -> Form ExamAutoOccurrenceAcceptForm
|
||||||
examAutoOccurrenceAcceptForm confirmData = identifyForm FIDExamAutoOccurrenceConfirm $ \html -> do
|
examAutoOccurrenceAcceptForm confirmData = identifyForm FIDExamAutoOccurrenceConfirm $ \html -> do
|
||||||
(confirmDataRes, confirmDataView) <- mreq secretJsonField "" confirmData
|
(confirmDataRes, confirmDataView) <- mreq secretJsonField "" confirmData
|
||||||
(acceptRes, acceptView) <- buttonForm' [BtnExamAutoOccurrenceAccept] mempty
|
let fs :: FieldSettings UniWorX
|
||||||
|
fs = (if maybe False eaofSuccess confirmData then id else set _fsAttrs [("disabled", "")]) ""
|
||||||
|
(acceptRes, acceptView) <- buttonForm'' [BtnExamAutoOccurrenceAccept] fs mempty
|
||||||
return (acceptRes *> confirmDataRes, toWidget html <> fvWidget confirmDataView <> acceptView)
|
return (acceptRes *> confirmDataRes, toWidget html <> fvWidget confirmDataView <> acceptView)
|
||||||
|
|
||||||
|
|
||||||
@ -199,7 +202,7 @@ postEAutoOccurrenceR tid ssh csh examn = do
|
|||||||
|
|
||||||
calcResult <- formResultMaybe calculateRes' $ \ExamAutoOccurrenceCalculateForm{..} -> do
|
calcResult <- formResultMaybe calculateRes' $ \ExamAutoOccurrenceCalculateForm{..} -> do
|
||||||
let autoOccurrenceResult = examAutoOccurrence eId examOccurrenceRule eaofConfig occurrences' participants'
|
let autoOccurrenceResult = examAutoOccurrence eId examOccurrenceRule eaofConfig occurrences' participants'
|
||||||
(eaofMapping, eaofAssignment) <- case autoOccurrenceResult of
|
(eaofMapping, eaofAssignment, eaofSuccess) <- case autoOccurrenceResult of
|
||||||
(Left e) -> do
|
(Left e) -> do
|
||||||
addMessageI Error e
|
addMessageI Error e
|
||||||
pure ( ExamOccurrenceMapping {
|
pure ( ExamOccurrenceMapping {
|
||||||
@ -207,8 +210,9 @@ postEAutoOccurrenceR tid ssh csh examn = do
|
|||||||
examOccurrenceMappingMapping = Map.empty
|
examOccurrenceMappingMapping = Map.empty
|
||||||
}
|
}
|
||||||
, Map.map (view _2) participants'
|
, Map.map (view _2) participants'
|
||||||
|
, False
|
||||||
)
|
)
|
||||||
(Right r) -> pure r
|
(Right res) -> pure $ uncurry (,,True) res
|
||||||
return $ Just ExamAutoOccurrenceAcceptForm{..}
|
return $ Just ExamAutoOccurrenceAcceptForm{..}
|
||||||
|
|
||||||
((confirmRes, confirmView), confirmEncoding) <- runFormPost $ examAutoOccurrenceAcceptForm calcResult
|
((confirmRes, confirmView), confirmEncoding) <- runFormPost $ examAutoOccurrenceAcceptForm calcResult
|
||||||
|
|||||||
@ -415,8 +415,12 @@ buttonForm = buttonForm' universeF
|
|||||||
|
|
||||||
-- | like `buttonForm`, but for a given list of buttons, i.e. a subset or for buttons outside the Finite typeclass
|
-- | like `buttonForm`, but for a given list of buttons, i.e. a subset or for buttons outside the Finite typeclass
|
||||||
buttonForm' :: (MonadHandler m, Button (HandlerSite m) a) => [a] -> Html -> MForm m (FormResult a, WidgetT (HandlerSite m) IO ())
|
buttonForm' :: (MonadHandler m, Button (HandlerSite m) a) => [a] -> Html -> MForm m (FormResult a, WidgetT (HandlerSite m) IO ())
|
||||||
buttonForm' btns csrf = do
|
buttonForm' btns = buttonForm'' btns ""
|
||||||
(res, ($ []) -> fViews) <- aFormToForm . disambiguateButtons $ combinedButtonField btns ""
|
|
||||||
|
-- | like `buttonForm'`, but for a given list of FieldSettings
|
||||||
|
buttonForm'' :: (MonadHandler m, Button (HandlerSite m) a) => [a] -> FieldSettings (HandlerSite m) -> Html -> MForm m (FormResult a, WidgetT (HandlerSite m) IO ())
|
||||||
|
buttonForm'' btns settings csrf = do
|
||||||
|
(res, ($ []) -> fViews) <- aFormToForm . disambiguateButtons $ combinedButtonField btns settings
|
||||||
return (res, [whamlet|
|
return (res, [whamlet|
|
||||||
$newline never
|
$newline never
|
||||||
#{csrf}
|
#{csrf}
|
||||||
|
|||||||
Reference in New Issue
Block a user