diff options
author | Joris | 2016-08-08 20:58:17 +0200 |
---|---|---|
committer | Joris | 2016-08-08 20:58:17 +0200 |
commit | 8816cf758119a6a2073e561c8df297a833630986 (patch) | |
tree | 20e63f3c0de15945b818a6d7a78359f9134b5e82 /src/client/elm/LoggedIn/Income/View.elm | |
parent | b54d8e45fc8784d8fa6eaa03f58536b7a19cf70b (diff) |
Show incomes in a table and update like payments are updated
Diffstat (limited to 'src/client/elm/LoggedIn/Income/View.elm')
-rw-r--r-- | src/client/elm/LoggedIn/Income/View.elm | 55 |
1 files changed, 18 insertions, 37 deletions
diff --git a/src/client/elm/LoggedIn/Income/View.elm b/src/client/elm/LoggedIn/Income/View.elm index 2b69806..5a2c18e 100644 --- a/src/client/elm/LoggedIn/Income/View.elm +++ b/src/client/elm/LoggedIn/Income/View.elm @@ -19,6 +19,8 @@ import View.Form as Form import View.Events exposing (onSubmitPrevDefault) import Dialog +import Dialog.AddIncome.Model as AddIncome +import Dialog.AddIncome.View as AddIncome import Msg exposing (Msg) @@ -29,33 +31,42 @@ import Model.Translations exposing (getMessage, getParamMessage) import Model.Payer exposing (useIncomesFrom) import Model.User exposing (UserId, User) import Model.View as View -import LoggedIn.Income.Model as IncomeModel +import LoggedIn.Income.Model as Income import LoggedIn.Msg as LoggedInMsg import LoggedIn.Income.Msg as IncomeMsg import View.Date as Date import LoggedIn.View.Format as Format - import View.Color as Color +import LoggedIn.Income.View.Table as Table -view : LoggedData -> IncomeModel.Model -> Html Msg +view : LoggedData -> Income.Model -> Html Msg view loggedData incomeModel = div [ class "income" ] [ case useIncomesFrom loggedData.users loggedData.incomes loggedData.payments of Just since -> cumulativeIncomesView loggedData since Nothing -> text "" - , h1 [] [ text <| getMessage "MonthlyNetIncomes" loggedData.translations ] - , addIncomeView loggedData incomeModel.addIncome - , incomesView loggedData + , div + [ class "textual monthlyNetIncomes" ] + [ h1 [] [ text <| getMessage "MonthlyNetIncomes" loggedData.translations ] + , AddIncome.button + "addIncome" + loggedData + (AddIncome.initialAdd loggedData.translations (Date.fromTime loggedData.currentTime)) + "AddIncome" + (text (getMessage "AddIncome" loggedData.translations)) + Nothing + ] + , Table.view loggedData incomeModel ] cumulativeIncomesView : LoggedData -> Time -> Html Msg cumulativeIncomesView loggedData since = let longDate = Date.longView (Date.fromTime since) loggedData.translations in div - [] + [ class "textual" ] [ h1 [] [ text <| getParamMessage [longDate] "CumulativeIncomesSince" loggedData.translations ] , ul [] @@ -75,36 +86,6 @@ cumulativeIncomesView loggedData since = ) ] -addIncomeView : LoggedData -> Form String IncomeModel.AddIncome -> Html Msg -addIncomeView loggedData addIncome = - let htmlMap = Html.map (Msg.UpdateLoggedIn << LoggedInMsg.IncomeMsg << IncomeMsg.AddIncomeMsg) - in Html.form - [ onSubmitPrevDefault Msg.NoOp ] - [ htmlMap <| Form.textInput loggedData.translations addIncome "income" "amount" - , htmlMap <| Form.textInput loggedData.translations addIncome "income" "date" - , button - [ class "add" - , case Form.getOutput addIncome of - Just data -> - onClick (Msg.UpdateLoggedIn <| LoggedInMsg.CreateIncome data.amount data.date) - Nothing -> - onClick (Msg.UpdateLoggedIn <| LoggedInMsg.IncomeMsg <| IncomeMsg.AddIncomeMsg <| Form.Submit) - ] - [ text (getMessage "Add" loggedData.translations) ] - ] - -incomesView : LoggedData -> Html Msg -incomesView loggedData = - ul - [ class "incomes" ] - ( loggedData.incomes - |> Dict.toList - |> List.filter ((==) loggedData.me << .userId << snd) - |> List.sortBy (.time << snd) - |> List.reverse - |> List.map (incomeView loggedData) - ) - incomeView : LoggedData -> (IncomeId, Income) -> Html Msg incomeView loggedData (incomeId, income) = li |