aboutsummaryrefslogtreecommitdiff
path: root/src/client/Update/LoggedIn/Account.elm
diff options
context:
space:
mode:
authorJoris2015-09-13 14:38:08 +0200
committerJoris2015-09-13 14:38:08 +0200
commit6ca60e32f0cbde913d171cd84ed7009ab4281284 (patch)
tree9d365a0e94cbcbfbc0b4e88d8e6cec7ada75fd28 /src/client/Update/LoggedIn/Account.elm
parent5babf01323bcb62a9880593165af70732f22751b (diff)
downloadbudget-6ca60e32f0cbde913d171cd84ed7009ab4281284.tar.gz
budget-6ca60e32f0cbde913d171cd84ed7009ab4281284.tar.bz2
budget-6ca60e32f0cbde913d171cd84ed7009ab4281284.zip
Adding UI to modify the income
Diffstat (limited to 'src/client/Update/LoggedIn/Account.elm')
-rw-r--r--src/client/Update/LoggedIn/Account.elm31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/client/Update/LoggedIn/Account.elm b/src/client/Update/LoggedIn/Account.elm
index ab07c2e..2d9cd87 100644
--- a/src/client/Update/LoggedIn/Account.elm
+++ b/src/client/Update/LoggedIn/Account.elm
@@ -3,13 +3,21 @@ module Update.LoggedIn.Account
, updateAccount
) where
+import Maybe
+
import Model.User exposing (UserId)
import Model.Payers exposing (..)
import Model.View.LoggedIn.Account exposing (..)
+import Utils.Maybe exposing (isJust)
+
type AccountAction =
ToggleDetail
| UpdatePayer UserId Int
+ | ToggleIncomeEdition
+ | UpdateIncomeEdition String
+ | UpdateEditionError String
+ | UpdateIncome Int
updateAccount : AccountAction -> Account -> Account
updateAccount action account =
@@ -18,3 +26,26 @@ updateAccount action account =
{ account | visibleDetail <- not account.visibleDetail }
UpdatePayer userId cost ->
{ account | payers <- updatePayers account.payers userId cost }
+ ToggleIncomeEdition ->
+ { account | incomeEdition <-
+ if isJust account.incomeEdition
+ then Nothing
+ else Just (initIncomeEdition (Maybe.withDefault 0 account.income))
+ }
+ UpdateIncomeEdition income ->
+ case account.incomeEdition of
+ Just incomeEdition ->
+ { account | incomeEdition <- Just { incomeEdition | income <- income } }
+ Nothing ->
+ account
+ UpdateEditionError error ->
+ case account.incomeEdition of
+ Just incomeEdition ->
+ { account | incomeEdition <- Just { incomeEdition | error <- Just error } }
+ Nothing ->
+ account
+ UpdateIncome amount ->
+ { account
+ | income <- Just amount
+ , incomeEdition <- Nothing
+ }