chore(profile): add (currently no-op) massinput for label-creation
This commit is contained in:
parent
f68facefe9
commit
a00afa2150
@ -65,3 +65,4 @@ ExamOfficeLabelsTip: Sie können hier Labels anlegen und verwalten, welche sie e
|
||||
ExamOfficeLabelName !ident-ok: Name
|
||||
ExamOfficeLabelStatus !ident-ok: Status
|
||||
ExamOfficeLabelPriority: Priorität
|
||||
ExamOfficeLabelAlreadyExists: Es existiert bereits ein Prüfungs-Label mit diesem Namen!
|
||||
|
||||
@ -63,3 +63,4 @@ ExamOfficeLabelsTip: Here you can add and manage labels, which you can assign ex
|
||||
ExamOfficeLabelName: Name
|
||||
ExamOfficeLabelStatus: Status
|
||||
ExamOfficeLabelPriority: Priority
|
||||
ExamOfficeLabelAlreadyExists: There already exists an exam label with this name!
|
||||
|
||||
@ -61,4 +61,7 @@ SelectColumn: Auswahl
|
||||
CsvExport: CSV-Export
|
||||
TableProportion c@Text of'@Text prop@Rational !ident-ok: #{c}/#{of'} (#{rationalToFixed2 (100 * prop)}%)
|
||||
TableProportionNoRatio c@Text of'@Text !ident-ok: #{c}/#{of'}
|
||||
TableExamFinished: Ergebnisse sichtbar ab
|
||||
TableExamFinished: Ergebnisse sichtbar ab
|
||||
TableExamOfficeLabel: Prüfungs-Label
|
||||
TableExamOfficeLabelStatus: Label-Farbe
|
||||
TableExamOfficeLabelPriority: Label-Priorität
|
||||
@ -61,4 +61,7 @@ SelectColumn: Selection
|
||||
CsvExport: CSV export
|
||||
TableProportion c of' prop: #{c}/#{of'} (#{rationalToFixed2 (100 * prop)}%)
|
||||
TableProportionNoRatio c of': #{c}/#{of'}
|
||||
TableExamFinished: Results visible from
|
||||
TableExamFinished: Results visible from
|
||||
TableExamOfficeLabel: Exam label
|
||||
TableExamOfficeLabelStatus: Label colour
|
||||
TableExamOfficeLabelPriority: Label priority
|
||||
@ -329,29 +329,49 @@ allocationNotificationForm = maybe (pure mempty) allocationNotificationForm' . (
|
||||
examOfficeForm :: Maybe ExamOfficeSettings -> AForm Handler ExamOfficeSettings
|
||||
examOfficeForm template = wFormToAForm $ do
|
||||
(_uid, User{userExamOfficeGetSynced,userExamOfficeGetLabels}) <- requireAuthPair
|
||||
currentRoute <- fromMaybe (error "examOfficeForm called from 404-handler") <$> liftHandler getCurrentRoute
|
||||
mr <- getMessageRender
|
||||
let
|
||||
userExamOfficeLabels = fromMaybe mempty $ eosettingsLabels <$> template
|
||||
eoLabelForm :: AForm Handler EOLabels
|
||||
eoLabelForm = wFormToAForm $ do
|
||||
eoLabelsForm :: AForm Handler EOLabels
|
||||
eoLabelsForm = wFormToAForm $ do
|
||||
let
|
||||
miAdd :: ListPosition -> Natural -> ListLength -> (Text -> Text) -> FieldView UniWorX -> Maybe (Form (Map ListPosition (Either ExamOfficeLabelName ExamOfficeLabelId) -> FormResult (Map ListPosition (Either ExamOfficeLabelName ExamOfficeLabelId))))
|
||||
miAdd = error "WIP"
|
||||
miAdd _ _ _ nudge submitView = Just $ \csrf -> do
|
||||
(addRes, addView) <- mpreq textField (fslI MsgExamOfficeLabelName & addName (nudge "name")) Nothing
|
||||
let
|
||||
addRes' = addRes <&> \nLabel oldData@(maybe 0 (succ . fst) . Map.lookupMax -> kStart) -> if
|
||||
| Set.member (Left nLabel) . Set.fromList $ Map.elems oldData
|
||||
-> FormFailure [mr MsgExamOfficeLabelAlreadyExists]
|
||||
| otherwise
|
||||
-> FormSuccess . Map.fromList $ [(kStart, Left nLabel)]
|
||||
return (addRes', $(widgetFile "profile/exam-office-labels/add"))
|
||||
|
||||
miCell :: ListPosition -> Either ExamOfficeLabelName ExamOfficeLabelId -> Maybe EOLabelData -> (Text -> Text) -> Form EOLabelData
|
||||
miCell = error "WIP"
|
||||
miCell _ eoLabel initRes nudge csrf = do
|
||||
labelIdent <- case eoLabel of
|
||||
Left lblName -> return lblName
|
||||
Right lblId -> do
|
||||
ExamOfficeLabel{examOfficeLabelName} <- liftHandler . runDB $ getJust lblId
|
||||
return examOfficeLabelName
|
||||
(statusRes, statusView) <- mreq (selectField optionsFinite) (fslI MsgExamOfficeLabelStatus & addName (nudge "status")) ((\(_,x,_) -> x) <$> initRes)
|
||||
(priorityRes, priorityView) <- mreq intField (fslI MsgExamOfficeLabelPriority & addName (nudge "priority")) (((\(_,_,x) -> x) <$> initRes) <|> Just 0)
|
||||
let
|
||||
res :: FormResult EOLabelData
|
||||
res = (,,) <$> (FormSuccess labelIdent) <*> statusRes <*> priorityRes
|
||||
return (res, $(widgetFile "profile/exam-office-labels/cell"))
|
||||
|
||||
miDelete :: Map ListPosition (Either ExamOfficeLabelName ExamOfficeLabelId) -> ListPosition -> MaybeT (MForm Handler) (Map ListPosition ListPosition)
|
||||
miDelete = error "WIP"
|
||||
miDelete = miDeleteList
|
||||
|
||||
miAddEmpty :: ListPosition -> Natural -> ListLength -> Set ListPosition
|
||||
miAddEmpty = error "WIP"
|
||||
miAddEmpty _ _ _ = Set.empty
|
||||
|
||||
miButtonAction :: forall p. p -> Maybe (SomeRoute UniWorX)
|
||||
-- miButtonAction :: forall p. PathPiece p => p -> Maybe (SomeRoute UniWorX)
|
||||
miButtonAction = error "WIP"
|
||||
miButtonAction :: forall p. PathPiece p => p -> Maybe (SomeRoute UniWorX)
|
||||
miButtonAction frag = Just . SomeRoute $ currentRoute :#: frag
|
||||
|
||||
miLayout :: ListLength -> Map ListPosition (Either ExamOfficeLabelName ExamOfficeLabelId, FormResult EOLabelData) -> Map ListPosition Widget -> Map ListPosition (FieldView UniWorX) -> Map (Natural, ListPosition) Widget -> Widget
|
||||
miLayout = error "WIP"
|
||||
miLayout lLength _ cellWdgts delButtons addWdgets = $(widgetFile "profile/exam-office-labels/layout")
|
||||
|
||||
miIdent :: Text
|
||||
miIdent = "exam-office-labels"
|
||||
@ -370,7 +390,7 @@ examOfficeForm template = wFormToAForm $ do
|
||||
<$ aformSection MsgFormExamOffice
|
||||
<*> apopt checkBoxField (fslI MsgExamOfficeGetSynced & setTooltip MsgExamOfficeGetSyncedTip) (eosettingsGetSynced <$> template)
|
||||
<*> apopt checkBoxField (fslI MsgExamOfficeGetLabels & setTooltip MsgExamOfficeGetLabelsTip) (eosettingsGetLabels <$> template)
|
||||
<*> eoLabelForm
|
||||
<*> eoLabelsForm
|
||||
else
|
||||
return . pure . fromMaybe (ExamOfficeSettings userExamOfficeGetSynced userExamOfficeGetLabels userExamOfficeLabels) $ template
|
||||
|
||||
|
||||
6
templates/profile/exam-office-labels/add.hamlet
Normal file
6
templates/profile/exam-office-labels/add.hamlet
Normal file
@ -0,0 +1,6 @@
|
||||
$newline never
|
||||
<td colspan=6>
|
||||
#{csrf}
|
||||
^{fvWidget addView}
|
||||
<td>
|
||||
^{fvWidget submitView}
|
||||
8
templates/profile/exam-office-labels/cell.hamlet
Normal file
8
templates/profile/exam-office-labels/cell.hamlet
Normal file
@ -0,0 +1,8 @@
|
||||
$newline never
|
||||
<td>
|
||||
^{labelIdent}
|
||||
<td>
|
||||
#{csrf}
|
||||
^{fvWidget statusView}
|
||||
<td>
|
||||
^{fvWidget priorityView}
|
||||
17
templates/profile/exam-office-labels/layout.hamlet
Normal file
17
templates/profile/exam-office-labels/layout.hamlet
Normal file
@ -0,0 +1,17 @@
|
||||
$newline never
|
||||
<table .table .table--striped .table--hover>
|
||||
<thead>
|
||||
<tr .table__row .table__row--head>
|
||||
<th .table__th>_{MsgTableExamOfficeLabel}
|
||||
<th .table__th>_{MsgTableExamOfficeLabelStatus}
|
||||
<th .table__th>_{MsgTableExamOfficeLabelPriority}
|
||||
<td>
|
||||
<tbody>
|
||||
$forall coord <- review liveCoords lLength
|
||||
<tr .massinput__cell .table__row>
|
||||
^{cellWdgts ! coord}
|
||||
<td>
|
||||
^{fvWidget (delButtons ! coord)}
|
||||
<tfoot>
|
||||
<tr .massinput__cell.massinput__cell--add>
|
||||
^{addWdgets ! (0, 0)}
|
||||
Reference in New Issue
Block a user