chore(avs): person search triggers status and contact search for unique results for added convenience
This commit is contained in:
parent
aa1d230e49
commit
5b9d757ca4
@ -93,7 +93,7 @@ validateAvsQueryPerson = do
|
|||||||
is _Just avsPersonQueryInternalPersonalNo ||
|
is _Just avsPersonQueryInternalPersonalNo ||
|
||||||
is _Just avsPersonQueryVersionNo
|
is _Just avsPersonQueryVersionNo
|
||||||
|
|
||||||
makeAvsStatusForm :: Maybe AvsQueryStatus -> Form AvsQueryStatus
|
makeAvsStatusForm :: Maybe AvsPersonId -> Form AvsQueryStatus
|
||||||
makeAvsStatusForm tmpl = identifyForm FIDAvsQueryStatus . validateForm validateAvsQueryStatus $ \html ->
|
makeAvsStatusForm tmpl = identifyForm FIDAvsQueryStatus . validateForm validateAvsQueryStatus $ \html ->
|
||||||
flip (renderAForm FormStandard) html $
|
flip (renderAForm FormStandard) html $
|
||||||
parseAvsIds <$> areq textField (fslI MsgAvsPersonId) (unparseAvsIds <$> tmpl)
|
parseAvsIds <$> areq textField (fslI MsgAvsPersonId) (unparseAvsIds <$> tmpl)
|
||||||
@ -103,15 +103,15 @@ makeAvsStatusForm tmpl = identifyForm FIDAvsQueryStatus . validateForm validateA
|
|||||||
where
|
where
|
||||||
nonemptys = filter (not . Text.null) $ Text.strip <$> Text.split (==',') txt
|
nonemptys = filter (not . Text.null) $ Text.strip <$> Text.split (==',') txt
|
||||||
ids = mapMaybe readMay nonemptys
|
ids = mapMaybe readMay nonemptys
|
||||||
unparseAvsIds :: AvsQueryStatus -> Text
|
unparseAvsIds :: AvsPersonId -> Text
|
||||||
unparseAvsIds (AvsQueryStatus ids) = Text.intercalate ", " $ tshow <$> Set.toAscList ids
|
unparseAvsIds = tshow . avsPersonId
|
||||||
|
|
||||||
validateAvsQueryStatus :: FormValidator AvsQueryStatus Handler ()
|
validateAvsQueryStatus :: FormValidator AvsQueryStatus Handler ()
|
||||||
validateAvsQueryStatus = do
|
validateAvsQueryStatus = do
|
||||||
AvsQueryStatus ids <- State.get
|
AvsQueryStatus ids <- State.get
|
||||||
guardValidation (MsgAvsQueryStatusInvalid $ tshow ids) $ not (null ids)
|
guardValidation (MsgAvsQueryStatusInvalid $ tshow ids) $ not (null ids)
|
||||||
|
|
||||||
makeAvsContactForm :: Maybe AvsQueryContact -> Form AvsQueryContact
|
makeAvsContactForm :: Maybe AvsPersonId -> Form AvsQueryContact
|
||||||
makeAvsContactForm tmpl = identifyForm FIDAvsQueryContact . validateForm validateAvsQueryContact $ \html ->
|
makeAvsContactForm tmpl = identifyForm FIDAvsQueryContact . validateForm validateAvsQueryContact $ \html ->
|
||||||
flip (renderAForm FormStandard) html $
|
flip (renderAForm FormStandard) html $
|
||||||
parseAvsIds <$> areq textField (fslI MsgAvsPersonId) (unparseAvsIds <$> tmpl) -- consider using cfAnySeparatedSet here
|
parseAvsIds <$> areq textField (fslI MsgAvsPersonId) (unparseAvsIds <$> tmpl) -- consider using cfAnySeparatedSet here
|
||||||
@ -121,8 +121,9 @@ makeAvsContactForm tmpl = identifyForm FIDAvsQueryContact . validateForm validat
|
|||||||
where
|
where
|
||||||
nonemptys = filter (not . Text.null) $ Text.strip <$> Text.split (==',') txt
|
nonemptys = filter (not . Text.null) $ Text.strip <$> Text.split (==',') txt
|
||||||
ids = mapMaybe (fmap AvsObjPersonId . readMay) nonemptys
|
ids = mapMaybe (fmap AvsObjPersonId . readMay) nonemptys
|
||||||
unparseAvsIds :: AvsQueryContact -> Text
|
unparseAvsIds :: AvsPersonId -> Text
|
||||||
unparseAvsIds (AvsQueryContact ids) = Text.intercalate ", " $ tshow <$> Set.toAscList ids
|
unparseAvsIds = tshow . avsPersonId
|
||||||
|
--unparseAvsIds (AvsQueryContact ids) = Text.intercalate ", " $ tshow <$> Set.toAscList ids
|
||||||
|
|
||||||
validateAvsQueryContact :: FormValidator AvsQueryContact Handler ()
|
validateAvsQueryContact :: FormValidator AvsQueryContact Handler ()
|
||||||
validateAvsQueryContact = do
|
validateAvsQueryContact = do
|
||||||
@ -161,19 +162,26 @@ postAdminAvsR = do
|
|||||||
|
|
||||||
((presult, pwidget), penctype) <- runFormPost $ makeAvsPersonForm Nothing
|
((presult, pwidget), penctype) <- runFormPost $ makeAvsPersonForm Nothing
|
||||||
|
|
||||||
let procFormPerson fr = do
|
let procFormPerson :: AvsQueryPerson -> Handler (Maybe (Maybe Widget, Maybe AvsPersonId))
|
||||||
|
procFormPerson fr = do
|
||||||
addMessage Info $ text2Html $ "Query: " <> tshow (toJSON fr)
|
addMessage Info $ text2Html $ "Query: " <> tshow (toJSON fr)
|
||||||
tryShow $ do
|
try (avsQuery fr) >>= \case
|
||||||
AvsResponsePerson pns <- avsQuery fr
|
Left err -> return $ Just (Just $ exceptionWgt err, Nothing)
|
||||||
return [whamlet|
|
Right (AvsResponsePerson pns) -> do
|
||||||
<ul>
|
let mapid = case Set.toList pns of
|
||||||
$forall p <- pns
|
[AvsDataPerson{avsPersonPersonID=apid}] -> Just apid
|
||||||
<li>^{jsonWidget p}
|
_ -> Nothing
|
||||||
|] -- <li>#{decodeUtf8 (Pretty.encodePretty (toJSON p))}
|
wgt = [whamlet|
|
||||||
mbPerson <- formResultMaybe presult (Just <<$>> procFormPerson)
|
<ul>
|
||||||
|
$forall p <- pns
|
||||||
((sresult, swidget), senctype) <- runFormPost $ makeAvsStatusForm Nothing
|
<li>^{jsonWidget p}
|
||||||
let procFormStatus fr = do
|
|] -- <li>#{decodeUtf8 (Pretty.encodePretty (toJSON p))}
|
||||||
|
return $ Just (toMaybe (notNull pns) wgt, mapid)
|
||||||
|
(mbPerson,mapid) <- fromMaybe (Nothing,Nothing) <$> formResultMaybe presult procFormPerson
|
||||||
|
|
||||||
|
((sresult', swidget), senctype) <- runFormPost $ makeAvsStatusForm mapid
|
||||||
|
let sresult = sresult' <|> maybe FormMissing (FormSuccess . AvsQueryStatus . Set.singleton) mapid -- use unique AvsId from PersonSearch for convenience, if form was empty
|
||||||
|
procFormStatus fr = do
|
||||||
addMessage Info $ text2Html $ "Status Query: " <> tshow (toJSON fr)
|
addMessage Info $ text2Html $ "Status Query: " <> tshow (toJSON fr)
|
||||||
tryShow $ do
|
tryShow $ do
|
||||||
AvsResponseStatus pns <- avsQuery fr
|
AvsResponseStatus pns <- avsQuery fr
|
||||||
@ -184,8 +192,9 @@ postAdminAvsR = do
|
|||||||
|]
|
|]
|
||||||
mbStatus <- formResultMaybe sresult (Just <<$>> procFormStatus)
|
mbStatus <- formResultMaybe sresult (Just <<$>> procFormStatus)
|
||||||
|
|
||||||
((cresult, cwidget), cenctype) <- runFormPost $ makeAvsContactForm Nothing
|
((cresult', cwidget), cenctype) <- runFormPost $ makeAvsContactForm mapid
|
||||||
let procFormContact fr = do
|
let cresult = cresult' <|> maybe FormMissing (FormSuccess . AvsQueryContact . Set.singleton . AvsObjPersonId) mapid -- use unique AvsId from PersonSearch for convenience, if form was empty
|
||||||
|
procFormContact fr = do
|
||||||
addMessage Info $ text2Html $ "Contact Query: " <> tshow (toJSON fr)
|
addMessage Info $ text2Html $ "Contact Query: " <> tshow (toJSON fr)
|
||||||
tryShow $ do
|
tryShow $ do
|
||||||
AvsResponseContact pns <- avsQuery fr
|
AvsResponseContact pns <- avsQuery fr
|
||||||
|
|||||||
@ -44,6 +44,10 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later
|
|||||||
<p>
|
<p>
|
||||||
Unverarbeitete Antwort: #
|
Unverarbeitete Antwort: #
|
||||||
^{answer}
|
^{answer}
|
||||||
|
$maybe apid <- mapid
|
||||||
|
<p>
|
||||||
|
Einzelne erhaltene AVS PersonId #{show apid} wurde auch gleich
|
||||||
|
in die Status und Contact Abfragen eingesetzt.
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
Reference in New Issue
Block a user