aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Model/Init.elm
diff options
context:
space:
mode:
authorJoris2016-03-31 00:06:50 +0200
committerJoris2016-03-31 00:13:25 +0200
commitc95e19407d492a0d4e9e14e320520fe29ce379e5 (patch)
treeca6a14ad1396af6a4bc36e17ce89278d5dbea0a0 /src/client/elm/Model/Init.elm
parentc542551ad043260e6a4a6569b4af5c748f7b6001 (diff)
downloadbudget-c95e19407d492a0d4e9e14e320520fe29ce379e5.tar.gz
budget-c95e19407d492a0d4e9e14e320520fe29ce379e5.tar.bz2
budget-c95e19407d492a0d4e9e14e320520fe29ce379e5.zip
Add init data in html page
Diffstat (limited to 'src/client/elm/Model/Init.elm')
-rw-r--r--src/client/elm/Model/Init.elm17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/client/elm/Model/Init.elm b/src/client/elm/Model/Init.elm
index 7fccf00..5db038d 100644
--- a/src/client/elm/Model/Init.elm
+++ b/src/client/elm/Model/Init.elm
@@ -1,10 +1,13 @@
module Model.Init
( Init
+ , initDecoder
) where
-import Model.Payment exposing (Payments)
-import Model.Income exposing (Incomes)
-import Model.User exposing (Users, UserId)
+import Json.Decode as Json exposing ((:=))
+
+import Model.Payment exposing (Payments, paymentsDecoder)
+import Model.Income exposing (Incomes, incomesDecoder)
+import Model.User exposing (Users, UserId, usersDecoder, userIdDecoder)
type alias Init =
{ users : Users
@@ -12,3 +15,11 @@ type alias Init =
, payments : Payments
, incomes : Incomes
}
+
+initDecoder : Json.Decoder Init
+initDecoder =
+ Json.object4 Init
+ ("users" := usersDecoder)
+ ("me" := userIdDecoder)
+ ("payments" := paymentsDecoder)
+ ("incomes" := incomesDecoder)