add table to list view
This commit is contained in:
@@ -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 $
|
||||
|
||||
Reference in New Issue
Block a user