From b2d4c0aa5a25dffa25269a80b30b50896de5a4bb Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Sun, 23 Feb 2025 18:47:01 +0100 Subject: fix schema decoding in frontend --- frontend/app/Schema.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'frontend') diff --git a/frontend/app/Schema.hs b/frontend/app/Schema.hs index 5f4ddae..5265d57 100644 --- a/frontend/app/Schema.hs +++ b/frontend/app/Schema.hs @@ -11,9 +11,9 @@ where import ACMS.API.REST.Collection.Paginated (Paginated (..)) import Control.Applicative ((<|>)) import Data.Aeson qualified as A +import Data.Aeson.Encoding.Internal qualified as AE import Data.Aeson.Key qualified as AK import Data.Aeson.KeyMap qualified as AM -import Data.List import Data.Map qualified as M import Data.Maybe import Data.Scientific (fromFloatDigits) @@ -51,7 +51,13 @@ instance A.FromJSON Schema where #ifdef ghcjs_HOST_OS instance A.FromJSONKey MisoString where - fromJSONKey = fromMisoString <$> A.fromJSONKey + fromJSONKey = A.FromJSONKeyText toMisoString + +instance A.ToJSONKey MisoString where + toJSONKey = + A.ToJSONKeyText + (AK.fromText . fromMisoString) + (AE.key . AK.fromText . fromMisoString) #endif data Property @@ -99,7 +105,7 @@ schemaTable collection schema paginated = thead_ [] $ [ tr_ [] $ [ th_ [] [text (toMisoString k)] - | k <- M.keys schema.properties + | k <- M.keys schema.properties ] ] tbody = @@ -128,9 +134,9 @@ schemaTable collection schema paginated = A.String s -> toMisoString s _ -> toMisoString (A.encode v) ] - | (k, p) <- M.assocs schema.properties + | (k, p) <- M.assocs schema.properties ] - | value <- paginated.data_ + | value <- paginated.data_ ] tfoot = let page, lastPage, perPage :: Int -- cgit v1.2.3