From a48e79e2f7c1ab1ffb52b86ef9e900c75c5d023b Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 12 Sep 2015 23:57:16 +0200 Subject: Adding UI income read-only --- src/client/Update/LoggedIn.elm | 9 ++++++--- src/client/Update/LoggedIn/Account.elm | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 src/client/Update/LoggedIn/Account.elm (limited to 'src/client/Update') diff --git a/src/client/Update/LoggedIn.elm b/src/client/Update/LoggedIn.elm index 03eb137..07f3426 100644 --- a/src/client/Update/LoggedIn.elm +++ b/src/client/Update/LoggedIn.elm @@ -9,12 +9,12 @@ import Dict import Model exposing (Model) import Model.User exposing (UserId) import Model.Payment exposing (..) -import Model.Payers exposing (..) import Model.View.LoggedInView exposing (..) import Model.View.LoggedIn.Add exposing (..) import Update.LoggedIn.Add exposing (..) import Update.LoggedIn.Monthly as UM +import Update.LoggedIn.Account as UA type LoggedAction = UpdateAdd AddPaymentAction @@ -25,6 +25,7 @@ type LoggedAction = | DeletePayment UserId Int Payments | UpdatePage Int Payments | UpdateMonthly UM.MonthlyAction + | UpdateAccount UA.AccountAction updateLoggedIn : Model -> LoggedAction -> LoggedInView -> LoggedInView updateLoggedIn model action loggedInView = @@ -38,7 +39,7 @@ updateLoggedIn model action loggedInView = | payments <- payments , currentPage <- 1 , add <- initAddPayment Punctual - , payers <- updatePayers loggedInView.payers userId cost + , account <- UA.updateAccount (UA.UpdatePayer userId cost) loggedInView.account , paymentsCount <- loggedInView.paymentsCount + 1 } AddMonthlyPayment id name cost -> @@ -53,7 +54,7 @@ updateLoggedIn model action loggedInView = DeletePayment userId cost payments -> { loggedInView | payments <- payments - , payers <- updatePayers loggedInView.payers userId -cost + , account <- UA.updateAccount (UA.UpdatePayer userId -cost) loggedInView.account , paymentsCount <- loggedInView.paymentsCount - 1 } UpdatePage page payments -> @@ -63,3 +64,5 @@ updateLoggedIn model action loggedInView = } UpdateMonthly monthlyAction -> { loggedInView | monthly <- UM.updateMonthly monthlyAction loggedInView.monthly } + UpdateAccount accountAction -> + { loggedInView | account <- UA.updateAccount accountAction loggedInView.account } diff --git a/src/client/Update/LoggedIn/Account.elm b/src/client/Update/LoggedIn/Account.elm new file mode 100644 index 0000000..ab07c2e --- /dev/null +++ b/src/client/Update/LoggedIn/Account.elm @@ -0,0 +1,20 @@ +module Update.LoggedIn.Account + ( AccountAction(..) + , updateAccount + ) where + +import Model.User exposing (UserId) +import Model.Payers exposing (..) +import Model.View.LoggedIn.Account exposing (..) + +type AccountAction = + ToggleDetail + | UpdatePayer UserId Int + +updateAccount : AccountAction -> Account -> Account +updateAccount action account = + case action of + ToggleDetail -> + { account | visibleDetail <- not account.visibleDetail } + UpdatePayer userId cost -> + { account | payers <- updatePayers account.payers userId cost } -- cgit v1.2.3