aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Update
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Update')
-rw-r--r--src/client/elm/Update/LoggedIn.elm37
-rw-r--r--src/client/elm/Update/LoggedIn/Account.elm16
-rw-r--r--src/client/elm/Update/LoggedIn/AddPayment.elm (renamed from src/client/elm/Update/LoggedIn/Add.elm)14
-rw-r--r--src/client/elm/Update/LoggedIn/Monthly.elm10
-rw-r--r--src/client/elm/Update/SignIn.elm7
5 files changed, 25 insertions, 59 deletions
diff --git a/src/client/elm/Update/LoggedIn.elm b/src/client/elm/Update/LoggedIn.elm
index 38901b2..1553141 100644
--- a/src/client/elm/Update/LoggedIn.elm
+++ b/src/client/elm/Update/LoggedIn.elm
@@ -1,6 +1,5 @@
module Update.LoggedIn
- ( LoggedAction(..)
- , updateLoggedIn
+ ( updateLoggedIn
) where
import Date
@@ -9,25 +8,17 @@ import Dict
import Model exposing (Model)
import Model.User exposing (UserId)
import Model.Payment exposing (..)
+import Model.Action.LoggedInAction exposing (..)
+import Model.Action.AccountAction exposing (..)
+import Model.Action.MonthlyAction as Monthly
import Model.View.LoggedInView exposing (..)
-import Model.View.LoggedIn.Add exposing (..)
+import Model.View.LoggedIn.AddPayment exposing (..)
-import Update.LoggedIn.Add exposing (..)
-import Update.LoggedIn.Monthly as UM
-import Update.LoggedIn.Account as UA
+import Update.LoggedIn.AddPayment exposing (updateAddPayment)
+import Update.LoggedIn.Monthly exposing (updateMonthly)
+import Update.LoggedIn.Account exposing (updateAccount)
-type LoggedAction =
- UpdateAdd AddPaymentAction
- | UpdatePayments Payments
- | AddPayment PaymentId String Int
- | AddMonthlyPayment PaymentId String Int
- | ToggleEdit PaymentId
- | DeletePayment Payment
- | UpdatePage Int
- | UpdateMonthly UM.MonthlyAction
- | UpdateAccount UA.AccountAction
-
-updateLoggedIn : Model -> LoggedAction -> LoggedInView -> LoggedInView
+updateLoggedIn : Model -> LoggedInAction -> LoggedInView -> LoggedInView
updateLoggedIn model action loggedInView =
case action of
UpdateAdd addPaymentAction ->
@@ -39,7 +30,7 @@ updateLoggedIn model action loggedInView =
in { loggedInView
| currentPage = 1
, add = initAddPayment Punctual
- , account = UA.updateAccount (UA.UpdatePayer loggedInView.account.me model.currentTime cost) loggedInView.account
+ , account = updateAccount (UpdatePayer loggedInView.account.me model.currentTime cost) loggedInView.account
, payments = newPayment :: loggedInView.payments
, paymentsCount = loggedInView.paymentsCount + 1
}
@@ -48,13 +39,13 @@ updateLoggedIn model action loggedInView =
| add = initAddPayment Monthly
, monthly =
let payment = Payment id (Date.fromTime model.currentTime) name cost loggedInView.account.me
- in UM.updateMonthly (UM.AddPayment payment) loggedInView.monthly
+ in updateMonthly (Monthly.AddPayment payment) loggedInView.monthly
}
ToggleEdit id ->
{ loggedInView | paymentEdition = if loggedInView.paymentEdition == Just id then Nothing else Just id }
DeletePayment payment ->
{ loggedInView
- | account = UA.updateAccount (UA.UpdatePayer payment.userId (Date.toTime payment.creation) -payment.cost) loggedInView.account
+ | account = updateAccount (UpdatePayer payment.userId (Date.toTime payment.creation) -payment.cost) loggedInView.account
, payments = deletePayment payment.id loggedInView.payments
, paymentsCount = loggedInView.paymentsCount - 1
}
@@ -63,6 +54,6 @@ updateLoggedIn model action loggedInView =
| currentPage = page
}
UpdateMonthly monthlyAction ->
- { loggedInView | monthly = UM.updateMonthly monthlyAction loggedInView.monthly }
+ { loggedInView | monthly = updateMonthly monthlyAction loggedInView.monthly }
UpdateAccount accountAction ->
- { loggedInView | account = UA.updateAccount accountAction loggedInView.account }
+ { loggedInView | account = updateAccount accountAction loggedInView.account }
diff --git a/src/client/elm/Update/LoggedIn/Account.elm b/src/client/elm/Update/LoggedIn/Account.elm
index c7a66dd..496fab1 100644
--- a/src/client/elm/Update/LoggedIn/Account.elm
+++ b/src/client/elm/Update/LoggedIn/Account.elm
@@ -1,26 +1,16 @@
module Update.LoggedIn.Account
- ( AccountAction(..)
- , updateAccount
+ ( updateAccount
) where
import Maybe
-import Time exposing (Time)
import Dict
-import Model.User exposing (UserId)
-import Model.Payer exposing (..)
+import Model.Payer exposing (updatePayers)
+import Model.Action.AccountAction exposing (..)
import Model.View.LoggedIn.Account exposing (..)
import Utils.Maybe exposing (isJust)
-type AccountAction =
- ToggleDetail
- | UpdatePayer UserId Time Int
- | ToggleIncomeEdition
- | UpdateIncomeEdition String
- | UpdateEditionError String
- | UpdateIncome Time Int
-
updateAccount : AccountAction -> Account -> Account
updateAccount action account =
case action of
diff --git a/src/client/elm/Update/LoggedIn/Add.elm b/src/client/elm/Update/LoggedIn/AddPayment.elm
index 92bdb7e..62eda85 100644
--- a/src/client/elm/Update/LoggedIn/Add.elm
+++ b/src/client/elm/Update/LoggedIn/AddPayment.elm
@@ -1,15 +1,9 @@
-module Update.LoggedIn.Add
- ( AddPaymentAction(..)
- , updateAddPayment
+module Update.LoggedIn.AddPayment
+ ( updateAddPayment
) where
-import Model.View.LoggedIn.Add exposing (..)
-
-type AddPaymentAction =
- UpdateName String
- | UpdateCost String
- | AddError (Maybe String) (Maybe String)
- | ToggleFrequency
+import Model.Action.AddPaymentAction exposing (..)
+import Model.View.LoggedIn.AddPayment exposing (..)
updateAddPayment : AddPaymentAction -> AddPayment -> AddPayment
updateAddPayment action addPayment =
diff --git a/src/client/elm/Update/LoggedIn/Monthly.elm b/src/client/elm/Update/LoggedIn/Monthly.elm
index 275b3e8..2505091 100644
--- a/src/client/elm/Update/LoggedIn/Monthly.elm
+++ b/src/client/elm/Update/LoggedIn/Monthly.elm
@@ -1,16 +1,10 @@
module Update.LoggedIn.Monthly
- ( MonthlyAction(..)
- , updateMonthly
+ ( updateMonthly
) where
-import Model.Payment exposing (Payment, PaymentId)
+import Model.Action.MonthlyAction exposing (..)
import Model.View.LoggedIn.Monthly exposing (..)
-type MonthlyAction =
- ToggleDetail
- | AddPayment Payment
- | DeletePayment PaymentId
-
updateMonthly : MonthlyAction -> Monthly -> Monthly
updateMonthly action monthly =
case action of
diff --git a/src/client/elm/Update/SignIn.elm b/src/client/elm/Update/SignIn.elm
index 961fb16..c0aaf33 100644
--- a/src/client/elm/Update/SignIn.elm
+++ b/src/client/elm/Update/SignIn.elm
@@ -1,13 +1,10 @@
module Update.SignIn
- ( SignInAction(..)
- , updateSignIn
+ ( updateSignIn
) where
+import Model.Action.SignInAction exposing (..)
import Model.View.SignInView exposing (..)
-type SignInAction =
- ErrorLogin String
-
updateSignIn : SignInAction -> SignInView -> SignInView
updateSignIn action signInView =
case action of