remove form from list collection page

This commit is contained in:
Alexander Foremny
2024-06-06 15:23:23 +02:00
parent febd2d7a24
commit a569f8d7a2

View File

@@ -10,9 +10,7 @@ where
import Api import Api
import Data.Aeson qualified as A import Data.Aeson qualified as A
import Data.Aeson.KeyMap qualified as AM import Data.Aeson.KeyMap qualified as AM
import Form qualified as F
import Miso import Miso
import Miso.String (toMisoString)
import Schema import Schema
data Model = Model data Model = Model
@@ -34,32 +32,16 @@ initialModel collection = do
data Action data Action
= NoOp = NoOp
| FormChanged A.Value
| FormSubmitted A.Value
deriving (Eq, Show) deriving (Eq, Show)
updateModel :: Action -> Model -> Effect Action Model updateModel :: Action -> Model -> Effect Action Model
updateModel NoOp m = noEff m updateModel NoOp m = noEff m
updateModel (FormChanged input) m = noEff m {input}
updateModel (FormSubmitted output) m =
m <# do
const NoOp <$> consoleLog (toMisoString (A.encode output))
viewModel :: Model -> View Action viewModel :: Model -> View Action
viewModel m = viewModel m =
div_ [] $ div_ [] $
[ schemaTable m.schema m.posts, [ h3_ [] [text "entities"],
viewSchema m.schema, schemaTable m.schema m.posts,
viewForm m.input m.schema, h3_ [] [text "schema"],
viewInput m.input viewSchema m.schema
] ]
viewForm :: A.Value -> Schema -> View Action
viewForm input =
fmap (either FormChanged FormSubmitted)
. flip F.runForm input
. schemaForm
viewInput :: A.Value -> View Action
viewInput input =
pre_ [] [text (toMisoString (A.encode input))]