feat(sheets): fetch school statement as statement default
This commit is contained in:
parent
44473b4575
commit
a39a0d7c87
@ -66,6 +66,12 @@ makeSheetForm cId msId template = identifyForm FIDsheet . validateForm validateS
|
||||
(Just sId) -> liftHandler $ runDB $ getFtIdMap sId
|
||||
MsgRenderer mr <- getMsgRenderer
|
||||
ctime <- ceilingQuarterHour <$> liftIO getCurrentTime
|
||||
mSchoolAuthorshipStatement <- liftHandler . runDB . runMaybeT $ do
|
||||
Entity _ Course{courseSchool} <- MaybeT . getEntity $ cId
|
||||
Entity _ School{..} <- MaybeT . getEntity $ courseSchool
|
||||
statementId <- MaybeT . return $ bool Nothing schoolSheetAuthorshipStatementDefinition (schoolSheetAuthorshipStatementMode /= SchoolAuthorshipStatementModeNone)
|
||||
MaybeT . getEntity $ statementId
|
||||
-- TODO: compare versions: school > msId if school statement is newer than msId statement, msId > school otherwise (TODO: add lastEdited to model)
|
||||
sheetPersonalisedFilesForm <- makeSheetPersonalisedFilesForm $ template >>= sfPersonalF
|
||||
flip (renderAForm FormStandard) html $ SheetForm
|
||||
<$> areq (textField & cfStrip & cfCI) (fslI MsgSheetName) (sfName <$> template)
|
||||
@ -99,7 +105,7 @@ makeSheetForm cId msId template = identifyForm FIDsheet . validateForm validateS
|
||||
<*> apopt checkBoxField (fslI MsgSheetAnonymousCorrection & setTooltip MsgSheetAnonymousCorrectionTip) (sfAnonymousCorrection <$> template)
|
||||
<*> correctorForm (maybe mempty sfCorrectors template)
|
||||
<* aformSection MsgSheetAuthorshipStatement
|
||||
<*> optionalActionA (apreq htmlField (fslI MsgSheetAuthorshipStatement) (join $ sfAuthorshipStatement <$> template)) (fslI MsgSheetAuthorshipStatementRequired & setTooltip MsgSheetAuthorshipStatementRequiredTip) (is _Just . sfAuthorshipStatement <$> template) -- TODO: if template is empty, use school definition as default -- TODO: disable option and set accordingly if school mode prevents edits
|
||||
<*> optionalActionA (apreq htmlField (fslI MsgSheetAuthorshipStatement) (join (sfAuthorshipStatement <$> template) <|> authorshipStatementDefinitionContent . entityVal <$> mSchoolAuthorshipStatement)) (fslI MsgSheetAuthorshipStatementRequired & setTooltip MsgSheetAuthorshipStatementRequiredTip) ((is _Just . sfAuthorshipStatement <$> template) <|> (pure $ is _Just mSchoolAuthorshipStatement)) -- TODO: disable option and set accordingly if school mode prevents edits
|
||||
where
|
||||
makeSheetPersonalisedFilesForm :: Maybe SheetPersonalisedFilesForm -> MForm Handler (AForm Handler SheetPersonalisedFilesForm)
|
||||
makeSheetPersonalisedFilesForm template' = do
|
||||
|
||||
Loading…
Reference in New Issue
Block a user