aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/app/Page/EditValue.hs
diff options
context:
space:
mode:
authorLibravatar Kierán Meinhardt <kmein@posteo.de>2024-10-13 09:55:20 +0200
committerLibravatar Kierán Meinhardt <kmein@posteo.de>2024-10-13 09:55:24 +0200
commit962db630a81a4040902c23c773df3069a48db0a3 (patch)
tree65c2208cd0fe98aa8979080cb22b84edc35253ef /frontend/app/Page/EditValue.hs
parent895772f1e76d0cdf12eba5a579ce889d585c9072 (diff)
move Collection types to common
Diffstat (limited to 'frontend/app/Page/EditValue.hs')
-rw-r--r--frontend/app/Page/EditValue.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/frontend/app/Page/EditValue.hs b/frontend/app/Page/EditValue.hs
index feacd4a..4ff867f 100644
--- a/frontend/app/Page/EditValue.hs
+++ b/frontend/app/Page/EditValue.hs
@@ -15,22 +15,22 @@ import Data.Maybe
import Effect (Eff)
import Form qualified as F
import Miso
-import Miso.String (MisoString, toMisoString)
+import Miso.String (toMisoString)
import Safe (headMay)
import Schema
+import Collection
data Model = Model
- { collection :: MisoString,
- fileName :: MisoString,
+ { collectionItem :: CollectionItem,
input :: Maybe A.Object,
schema :: Schema
}
deriving (Show, Eq)
-initialModel :: MisoString -> MisoString -> JSM (Either SomeException Model)
-initialModel collection fileName = do
- schema' <- try (API.REST.Collection.schema collection)
- input' <- try (headMay <$> API.REST.Collection.read collection fileName)
+initialModel :: CollectionItem -> JSM (Either SomeException Model)
+initialModel collectionItem = do
+ schema' <- try (API.REST.Collection.schema collectionItem.collection)
+ input' <- try (headMay <$> API.REST.Collection.read collectionItem)
pure do
schema <- schema'
input <- input'
@@ -43,7 +43,7 @@ update__formChanged (Just -> input) = Action $ \m -> (noEff m {input}, [])
update__formSubmitted :: A.Object -> Action
update__formSubmitted output = Action $ \m ->
- (m <# do update__entityWritten <$> try (API.REST.Collection.update m.collection m.fileName output), [])
+ (m <# do update__entityWritten <$> try (API.REST.Collection.update m.collectionItem output), [])
update__entityWritten :: Either SomeException A.Object -> Action
update__entityWritten _ = Action $ \m -> (noEff m, [])