From 8816cf758119a6a2073e561c8df297a833630986 Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 8 Aug 2016 20:58:17 +0200 Subject: Show incomes in a table and update like payments are updated --- src/client/elm/LoggedIn/Update.elm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/client/elm/LoggedIn/Update.elm') diff --git a/src/client/elm/LoggedIn/Update.elm b/src/client/elm/LoggedIn/Update.elm index db851f1..68e840e 100644 --- a/src/client/elm/LoggedIn/Update.elm +++ b/src/client/elm/LoggedIn/Update.elm @@ -15,6 +15,7 @@ import Form import Model exposing (Model) import Model.Translations exposing (getMessage) import Model.Payment as Payment exposing (Payment, Frequency(..)) +import Model.Income as Income exposing (Income) import Server import LoggedData @@ -139,6 +140,24 @@ update model msg loggedIn = , Cmd.none ) + LoggedInMsg.EditIncome incomeId amount date -> + ( loggedIn + , Server.editIncome incomeId amount date + |> Task.perform + (always LoggedInMsg.NoOp) + (always <| LoggedInMsg.ValidateEditIncome incomeId amount date) + ) + + LoggedInMsg.ValidateEditIncome incomeId amount date -> + let updatedIncome = Income loggedIn.me (Date.toTime date) amount + updateIncome mbIncome = + case mbIncome of + Just _ -> Just updatedIncome + Nothing -> Just updatedIncome + in ( { loggedIn | incomes = Dict.update incomeId updateIncome loggedIn.incomes } + , Cmd.none + ) + LoggedInMsg.DeleteIncome incomeId -> ( loggedIn , Server.deleteIncome incomeId -- cgit v1.2.3