From 4a394d2050ed2b31056ee6b50e0216cff7df2c6c Mon Sep 17 00:00:00 2001 From: SJost Date: Thu, 18 Oct 2018 16:38:54 +0200 Subject: [PATCH] Labels adjusted, HelpForm not working before Login due to Modal-Login not being hidden properly, see #212 --- .vscode/tasks.json | 12 ++++++++++++ messages/uniworx/de.msg | 8 ++++++++ src/Foundation.hs | 4 ++-- src/Handler/Home.hs | 25 ++++++++++++++++--------- 4 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..6c2838596 --- /dev/null +++ b/.vscode/tasks.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index 091e95dd3..6d36a3dc0 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -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! diff --git a/src/Foundation.hs b/src/Foundation.hs index e32503b44..4bdcf5e5b 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -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 diff --git a/src/Handler/Home.hs b/src/Handler/Home.hs index cd82660fe..2b3fce6d3 100644 --- a/src/Handler/Home.hs +++ b/src/Handler/Home.hs @@ -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