diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-06-04 15:42:33 +0200 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-06-04 15:42:33 +0200 |
commit | d5f3f2333a4a167054c0a8556dfd8cd87f955595 (patch) | |
tree | aeb587ac7fb8c606c5e7f042459a784aff75a896 /frontend/app/Schema.hs | |
parent | ed753b04104b27a9b258f174a501e2ae058b41ee (diff) |
add table to list view
Diffstat (limited to 'frontend/app/Schema.hs')
-rw-r--r-- | frontend/app/Schema.hs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/frontend/app/Schema.hs b/frontend/app/Schema.hs index e2d2e15..517439d 100644 --- a/frontend/app/Schema.hs +++ b/frontend/app/Schema.hs @@ -4,6 +4,7 @@ module Schema ( Schema, viewSchema, + schemaTable, schemaForm, ) where @@ -65,6 +66,35 @@ viewSchema schema = ) <$> (M.toList properties) +schemaTable :: Schema -> [A.Value] -> View action +schemaTable schema values = + table_ [] [thead, tbody] + where + thead = + thead_ [] $ + case schema.type_ of + Object properties -> + [ tr_ [] $ + [ th_ [] [text (toMisoString k)] + | k <- M.keys properties + ] + ] + tbody = tbody_ [] $ + case schema.type_ of + Object properties -> + [ tr_ + [] + [ td_ [] $ + [ text $ + case getO (AK.fromString k) value of + A.String s -> toMisoString s + value -> toMisoString (A.encode value) + ] + | k <- M.keys properties + ] + | value <- values + ] + schemaForm :: Schema -> F.Form A.Value A.Value schemaForm schema = fmap mergeJson . sequence $ |