From 6b090b3bdef7108d51d93207e28b148c121767aa Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 4 Jan 2016 00:34:48 +0100 Subject: Simplify server communicaitons in client --- src/client/elm/Model/Action.elm | 6 ++---- src/client/elm/Model/Init.elm | 16 ++++++++++++++++ src/client/elm/Model/View/LoggedInView.elm | 15 ++++++++------- 3 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 src/client/elm/Model/Init.elm (limited to 'src/client/elm/Model') diff --git a/src/client/elm/Model/Action.elm b/src/client/elm/Model/Action.elm index 7267259..60c1aca 100644 --- a/src/client/elm/Model/Action.elm +++ b/src/client/elm/Model/Action.elm @@ -5,17 +5,15 @@ module Model.Action import Time exposing (Time) import Signal exposing (Address) -import Model.User exposing (Users, UserId) -import Model.Payment exposing (Payments) -import Model.Payer exposing (Payers) import Model.Action.SignInAction exposing (SignInAction) import Model.Action.LoggedInAction exposing (LoggedInAction) +import Model.Init exposing (Init) type Action = NoOp | SignIn String | UpdateTime Time - | GoLoggedInView Users UserId Payments Payments Int Payers + | GoLoggedInView Init | UpdateSignIn SignInAction | UpdateLoggedIn LoggedInAction | GoSignInView diff --git a/src/client/elm/Model/Init.elm b/src/client/elm/Model/Init.elm new file mode 100644 index 0000000..490321b --- /dev/null +++ b/src/client/elm/Model/Init.elm @@ -0,0 +1,16 @@ +module Model.Init + ( Init + ) where + +import Model.Payment exposing (Payments) +import Model.Payer exposing (Payers) +import Model.User exposing (Users, UserId) + +type alias Init = + { users : Users + , me : UserId + , payments : Payments + , monthlyPayments : Payments + , paymentsCount : Int + , payers : Payers + } diff --git a/src/client/elm/Model/View/LoggedInView.elm b/src/client/elm/Model/View/LoggedInView.elm index 75285b1..2df3525 100644 --- a/src/client/elm/Model/View/LoggedInView.elm +++ b/src/client/elm/Model/View/LoggedInView.elm @@ -6,6 +6,7 @@ module Model.View.LoggedInView import Model.User exposing (Users, UserId) import Model.Payment exposing (Payments, PaymentFrequency(..)) import Model.Payer exposing (Payers) +import Model.Init exposing (..) import Model.View.LoggedIn.AddPayment exposing (..) import Model.View.LoggedIn.Edition exposing (..) import Model.View.LoggedIn.Monthly exposing (..) @@ -22,14 +23,14 @@ type alias LoggedInView = , currentPage : Int } -initLoggedInView : Users -> UserId -> Payments -> Payments -> Int -> Payers -> LoggedInView -initLoggedInView users me monthlyPayments payments paymentsCount payers = - { users = users +initLoggedInView : Init -> LoggedInView +initLoggedInView init = + { users = init.users , add = initAddPayment Punctual - , monthly = initMonthly monthlyPayments - , account = initAccount me payers - , payments = payments - , paymentsCount = paymentsCount + , monthly = initMonthly init.monthlyPayments + , account = initAccount init.me init.payers + , payments = init.payments + , paymentsCount = init.paymentsCount , paymentEdition = Nothing , currentPage = 1 } -- cgit v1.2.3