diff --git a/src/Handler/Admin/Avs.hs b/src/Handler/Admin/Avs.hs index 82d739bb8..d117376e8 100644 --- a/src/Handler/Admin/Avs.hs +++ b/src/Handler/Admin/Avs.hs @@ -93,7 +93,7 @@ validateAvsQueryPerson = do is _Just avsPersonQueryInternalPersonalNo || is _Just avsPersonQueryVersionNo -makeAvsStatusForm :: Maybe AvsQueryStatus -> Form AvsQueryStatus +makeAvsStatusForm :: Maybe AvsPersonId -> Form AvsQueryStatus makeAvsStatusForm tmpl = identifyForm FIDAvsQueryStatus . validateForm validateAvsQueryStatus $ \html -> flip (renderAForm FormStandard) html $ parseAvsIds <$> areq textField (fslI MsgAvsPersonId) (unparseAvsIds <$> tmpl) @@ -103,15 +103,15 @@ makeAvsStatusForm tmpl = identifyForm FIDAvsQueryStatus . validateForm validateA where nonemptys = filter (not . Text.null) $ Text.strip <$> Text.split (==',') txt ids = mapMaybe readMay nonemptys - unparseAvsIds :: AvsQueryStatus -> Text - unparseAvsIds (AvsQueryStatus ids) = Text.intercalate ", " $ tshow <$> Set.toAscList ids + unparseAvsIds :: AvsPersonId -> Text + unparseAvsIds = tshow . avsPersonId validateAvsQueryStatus :: FormValidator AvsQueryStatus Handler () validateAvsQueryStatus = do AvsQueryStatus ids <- State.get guardValidation (MsgAvsQueryStatusInvalid $ tshow ids) $ not (null ids) -makeAvsContactForm :: Maybe AvsQueryContact -> Form AvsQueryContact +makeAvsContactForm :: Maybe AvsPersonId -> Form AvsQueryContact makeAvsContactForm tmpl = identifyForm FIDAvsQueryContact . validateForm validateAvsQueryContact $ \html -> flip (renderAForm FormStandard) html $ parseAvsIds <$> areq textField (fslI MsgAvsPersonId) (unparseAvsIds <$> tmpl) -- consider using cfAnySeparatedSet here @@ -121,8 +121,9 @@ makeAvsContactForm tmpl = identifyForm FIDAvsQueryContact . validateForm validat where nonemptys = filter (not . Text.null) $ Text.strip <$> Text.split (==',') txt ids = mapMaybe (fmap AvsObjPersonId . readMay) nonemptys - unparseAvsIds :: AvsQueryContact -> Text - unparseAvsIds (AvsQueryContact ids) = Text.intercalate ", " $ tshow <$> Set.toAscList ids + unparseAvsIds :: AvsPersonId -> Text + unparseAvsIds = tshow . avsPersonId + --unparseAvsIds (AvsQueryContact ids) = Text.intercalate ", " $ tshow <$> Set.toAscList ids validateAvsQueryContact :: FormValidator AvsQueryContact Handler () validateAvsQueryContact = do @@ -161,19 +162,26 @@ postAdminAvsR = do ((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) - tryShow $ do - AvsResponsePerson pns <- avsQuery fr - return [whamlet| -