diff --git a/src/Handler/Admin/Avs.hs b/src/Handler/Admin/Avs.hs index 6376f8727..b8283650b 100644 --- a/src/Handler/Admin/Avs.hs +++ b/src/Handler/Admin/Avs.hs @@ -654,21 +654,30 @@ getAdminAvsUserR uuid = do Es erfolgte damit aber noch kein Update der FRADrive Daten.

-
Info Person Contact
+
InfoPersonContact
(bevorzugt) -
+
$case mbContact $of Left err Fehler: #{tshow err} $of Right contactInfo #{decodeUtf8 (Pretty.encodePretty (toJSON contactInfo))} -
PersonStatus und mehrere PersoSearch
+
PersonStatus und mehrere PersonSearch
(benötigt mehrere AVS Abfragen) -
+
$maybe dataPerson <- mbDataPerson #{decodeUtf8 (Pretty.encodePretty (toJSON dataPerson))} $nothing - Keine Daten erhalten. + Keine Daten erhalten. +

+ Provisorische formatierte Ansicht +

+ Generisch formatierte Ansicht, die zeigt, in welche Richtung die Endansicht gehen könnte. + In der Endansicht wären nur ausgewählte Felder mit besserer Bennenung in einer manuell gewählten Reihenfolge sichtbar. +

+ ^{foldMap jsonWidget mbContact} +

+ ^{foldMap jsonWidget mbDataPerson} |] let heading = [whamlet|_{MsgAvsPersonNo} #{userAvsNoPerson}|] siteLayout heading $ do diff --git a/src/Handler/Utils/Widgets.hs b/src/Handler/Utils/Widgets.hs index 6f70a5d57..0d50aaa20 100644 --- a/src/Handler/Utils/Widgets.hs +++ b/src/Handler/Utils/Widgets.hs @@ -13,7 +13,7 @@ import Text.Hamlet (shamletFile) import Handler.Utils.DateTime import qualified Data.Char as Char - +import qualified Data.HashMap.Strict as Aeson -- ON UPDATE replace with: import qualified Data.Aeson.KeyMap as Aeson --------- -- Simple utilities for consistent display @@ -198,3 +198,36 @@ roomReferenceWidget RoomReferenceLink{..} = $(widgetFile "widgets/room-reference where linkText = uriToString id roomRefLink mempty instrModal = modal (i18n MsgRoomReferenceLinkInstructions) $ Right $(widgetFile "widgets/room-reference/link-instructions-modal") + + +---------- +-- JSON -- +---------- + +-- Data.Aeson.Encode.Pretty.encodePretty did not render in Html properly, hence jsonWidget +jsonWidget :: ToJSON a => a -> Widget +jsonWidget x = jsonWidgetAux $ toJSON x + where + jsonWidgetAux :: Value -> Widget + jsonWidgetAux Null = [whamlet|Null|] + jsonWidgetAux (Bool b) = toWidget $ boolSymbol b + jsonWidgetAux (String s) = [whamlet|#{s}|] + jsonWidgetAux (Number n) = [whamlet|#{show n}|] + jsonWidgetAux (Array l) + | 1 >= length l = foldMap jsonWidgetAux l -- empty arrays don't show + | otherwise = + [whamlet| +

    + $forall x <- sort l +
  • ^{jsonWidgetAux x} + |] + jsonWidgetAux (Object o) = case Aeson.toList o of -- toAscList not supported + [ ] -> mempty -- empty objects don't show + [(_,v)] -> jsonWidgetAux v + r -> [whamlet| +
    + $forall (k,v) <- sort r +
    #{k} +
    ^{jsonWidgetAux v} + |] + \ No newline at end of file diff --git a/src/Utils/Avs.hs b/src/Utils/Avs.hs index e1c3bc4f9..b366bac50 100644 --- a/src/Utils/Avs.hs +++ b/src/Utils/Avs.hs @@ -68,7 +68,7 @@ mkAvsQuery :: BaseUrl -> BasicAuthData -> ClientEnv -> AvsQuery mkAvsQuery _ _ _ = AvsQuery { avsQueryPerson = \_ -> return . Right $ AvsResponsePerson mempty , avsQueryStatus = \_ -> return . Right $ AvsResponseStatus mempty - , avsQueryContact = \_ -> return . Right $ AvsResponseContact $ Set.singleton $ AvsDataContact (AvsPersonId 1234567) (AvsPersonInfo "AVSNO:123" "Heribert" "Sumpfmeier" (-1) Nothing Nothing Nothing Nothing) (AvsFirmInfo "Lange Firma" 7 "Kurz" Nothing Nothing Nothing Nothing Nothing Nothing) + , avsQueryContact = \_ -> return . Right $ AvsResponseContact $ Set.singleton $ AvsDataContact (AvsPersonId 1234567) (AvsPersonInfo "123123123" "Heribert" "Sumpfmeier" (-1) Nothing Nothing Nothing Nothing) (AvsFirmInfo "Lange Firma" 7 "Kurz" Nothing Nothing Nothing Nothing Nothing Nothing) , avsQuerySetLicences = \_ -> return . Right $ AvsResponseSetLicences mempty , avsQueryGetAllLicences = return . Right $ AvsResponseGetLicences mempty }