From c229a013767f4d9605fd74eb46f5eb8e4202be9e Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Tue, 16 Apr 2019 15:39:21 +0200 Subject: [PATCH] cbody added --- messages/uniworx/de.msg | 2 ++ src/Handler/Utils/Communication.hs | 21 ++++----------------- src/Jobs/Types.hs | 1 + 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index 84c01ecaa..a809cde7e 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -738,7 +738,9 @@ MassInputDeleteCell: Entfernen NavigationFavourites: Favoriten CommSubject: Betreff +CommBody: Nachricht CommRecipients: Empfänger +CommRecipientsSelectBy: Auswahl nach CommDuplicateRecipients n@Int: #{tshow n} #{pluralDE n "doppelter" "doppelte"} Empfänger ignoriert CommSuccess n@Int: Nachricht wurde an #{tshow n} Empfänger versandt diff --git a/src/Handler/Utils/Communication.hs b/src/Handler/Utils/Communication.hs index dc8d6fe54..abc9d4ed0 100644 --- a/src/Handler/Utils/Communication.hs +++ b/src/Handler/Utils/Communication.hs @@ -92,24 +92,10 @@ commR CommunicationRoute{..} = do , pure ( AddRecipientCustom , Set.fromList . map (Left . CI.mk) <$> apreq multiEmailField (fslI AddRecipientCustom & addName (nudge $ toPathPiece AddRecipientCustom)) Nothing ) ] - (addRes, addWdgt) <- multiActionM addOptions ("foobar" & addName (nudge "select")) Nothing csrf - -- lookupUserDisplayName :: UserId -> UserDisplayName - -- lookupUserDisplayName <- liftHandlerT . runDB $ do - -- let uids = toListOf (_FormSuccess . folded . _Right) addRes - -- names <- forM uids getJustEntity - -- return $ \uid -> case filter ((== uid) . entityKey) names of - -- [Entity _ User{..}] -> userDisplayName - -- _other -> error "UserId lookpup failed" + (addRes, addWdgt) <- multiActionM addOptions (fslI MsgCommRecipientsSelectBy & addName (nudge "select")) Nothing csrf let addRes' = addRes <&> \newSet oldMap -> - -- if - -- | collisions <- newSet `Set.intersection` Set.fromList (Map.elems oldMap) - -- , not $ Set.null collisions -> - -- -- FormFailure [ mr . MsgCommDuplicateRecipients . map (either CI.original lookupUserDisplayName) $ Set.toList collisions ] - -- FormFailure [ mr . MsgCommDuplicateRecipients $ Set.size collisions ] - -- | otherwise -> FormSuccess . Map.fromList . zip [maybe 0 (succ . fst) (Map.lookupMax oldMap)..] $ Set.toList newSet - let freshSet = newSet `Set.difference` Set.fromList (Map.elems oldMap) - in FormSuccess . Map.fromList . zip [maybe 0 (succ . fst) (Map.lookupMax oldMap)..] $ Set.toList freshSet - + let freshSet = newSet `Set.difference` Set.fromList (Map.elems oldMap) + in FormSuccess . Map.fromList . zip [maybe 0 (succ . fst) (Map.lookupMax oldMap)..] $ Set.toList freshSet addWdgt' = mconcat [ toWidget csrf, addWdgt, fvInput submitView ] return (addRes', addWdgt') @@ -129,6 +115,7 @@ commR CommunicationRoute{..} = do ((commRes,commWdgt),commEncoding) <- runFormPost . identifyForm FIDCommunication . renderAForm FormStandard $ Communication <$> recipientAForm <*> aopt textField (fslI MsgCommSubject) Nothing + <*> areq htmlField (fslI MsgCommBody) Nothing formResult commRes $ \comm -> do runDBJobs $ queueDBJob =<< mapReaderT lift (crJob comm) addMessageI Success . MsgCommSuccess . Set.size $ cRecipients comm diff --git a/src/Jobs/Types.hs b/src/Jobs/Types.hs index 0aa6afe47..a7b1c7c27 100644 --- a/src/Jobs/Types.hs +++ b/src/Jobs/Types.hs @@ -55,6 +55,7 @@ deriveJSON defaultOptions data Communication = Communication { cRecipients :: Set (Either UserEmail UserId) , cSubject :: Maybe Text + , cBody :: Html } deriving (Eq, Ord, Read, Show, Generic, Typeable) instance Hashable Communication