Labels adjusted, HelpForm not working before Login due to Modal-Login not being hidden properly, see #212

This commit is contained in:
SJost 2018-10-18 16:38:54 +02:00
parent 033e3a8ad8
commit 4a394d2050
4 changed files with 38 additions and 11 deletions

12
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,12 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo Hello"
}
]
}

View File

@ -385,4 +385,12 @@ SheetCreateExisting: Folgende Pseudonyme haben bereits abgegeben:
UserAccountDeleted name@Text: Konto für #{name} wurde gelöscht!
HelpAnswer: Anfrage von
HelpUser: Benutzeraccount Uni2Work
HelpAnonymous: Anonym (Keine Antwort möglich)
HelpEMail: E-Mail (ohne Login)
HelpRequest: Supportanfrage / Verbesserungsvorschlag
HelpProblemPage: Problematische Seite
Dummy: TODO Message not defined!

View File

@ -813,7 +813,7 @@ defaultLinks = -- Define the menu items of the header.
{ menuItemLabel = "Hilfe"
, menuItemIcon = Just "question"
, menuItemRoute = HelpR
, menuItemModal = True
, menuItemModal = True -- TODO: Does not work yet, issue #212
, menuItemAccessCallback' = return True
}
, NavbarRight $ MenuItem
@ -827,7 +827,7 @@ defaultLinks = -- Define the menu items of the header.
{ menuItemLabel = "Login"
, menuItemIcon = Just "sign-in-alt"
, menuItemRoute = AuthR LoginR
, menuItemModal = True
, menuItemModal = True -- TODO: Does not work yet, issue #212
, menuItemAccessCallback' = isNothing <$> maybeAuthPair
}
, NavbarSecondary $ MenuItem

View File

@ -3,6 +3,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE IncoherentInstances #-} -- why is this needed? Instance for "display deadline" ought to be clear
@ -238,7 +239,7 @@ getVersionR = selectRep $ do
data HelpIdentOptions = HIAnonymous | HIUser | HIEmail
data HelpIdentOptions = HIUser | HIEmail | HIAnonymous
deriving (Eq, Ord, Bounded, Enum, Show, Read)
$( return [] ) -- forces order of splices, error otherwise, see https://ghc.haskell.org/trac/ghc/ticket/9813
@ -250,7 +251,10 @@ instance PathPiece HelpIdentOptions where
fromPathPiece = finiteFromPathPiece
instance RenderMessage UniWorX HelpIdentOptions where
renderMessage _ _ opt = tshow opt -- TODO
renderMessage foundation ls = renderMessage foundation ls . \case
HIUser -> MsgHelpUser
HIEmail -> MsgHelpEMail
HIAnonymous -> MsgHelpAnonymous
data HelpForm = HelpForm
{ hfReferer:: Maybe Text
@ -260,16 +264,19 @@ data HelpForm = HelpForm
helpForm :: Maybe Text -> Maybe UserId -> AForm _ HelpForm
helpForm mReferer mUid = HelpForm
<$> maybe (pure Nothing) (fmap Just . aforced textField (fslI MsgDummy)) mReferer
<*> multiActionA (fslI MsgDummy) identActions (HIUser <$ mUid)
<*> (unTextarea <$> areq textareaField (fslI MsgDummy) Nothing)
<$> maybe (pure Nothing) (fmap Just . aforced textField (fslI MsgHelpProblemPage)) mReferer
<*> multiActionA (fslI MsgHelpAnswer) identActions (HIUser <$ mUid)
<*> (unTextarea <$> areq textareaField (fslI MsgHelpRequest) Nothing)
<* submitButton
where
identActions :: Map _ (AForm _ (Either (Maybe Email) UserId))
identActions = Map.fromList . catMaybes $
[ ( HIUser,) . pure . Right <$> mUid
, Just (HIAnonymous, pure (Left Nothing))
, Just (HIEmail, Left . Just <$> apreq emailField (fslI MsgDummy) Nothing)
identActions = Map.fromList $ case mUid of
(Just uid) -> (HIUser, pure $ Right uid):defaultActions
Nothing -> defaultActions
defaultActions =
[ (HIEmail, Left . Just <$> apreq emailField (fslI MsgEMail) Nothing)
, (HIAnonymous, pure $ Left Nothing)
]
getHelpR :: Handler Html