aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/Income
diff options
context:
space:
mode:
authorJoris2017-03-24 09:21:04 +0000
committerJoris2017-03-24 09:21:04 +0000
commitcfca18262c1ff48dcb683ddab7d03cf8e55573ff (patch)
tree8a438430cee7411259fc395d8f3898488e85d750 /src/client/elm/LoggedIn/Income
parent293eb8295162bf0a038f488237db9c9d1316c04d (diff)
Features/categories
Diffstat (limited to 'src/client/elm/LoggedIn/Income')
-rw-r--r--src/client/elm/LoggedIn/Income/Model.elm15
-rw-r--r--src/client/elm/LoggedIn/Income/Update.elm12
-rw-r--r--src/client/elm/LoggedIn/Income/View.elm33
-rw-r--r--src/client/elm/LoggedIn/Income/View/Table.elm6
4 files changed, 33 insertions, 33 deletions
diff --git a/src/client/elm/LoggedIn/Income/Model.elm b/src/client/elm/LoggedIn/Income/Model.elm
index cf1bf57..7d852b9 100644
--- a/src/client/elm/LoggedIn/Income/Model.elm
+++ b/src/client/elm/LoggedIn/Income/Model.elm
@@ -3,12 +3,13 @@ module LoggedIn.Income.Model exposing
, AddIncome
, init
, initForm
+ , validation
)
import Date exposing (Date)
import Form exposing (Form)
-import Form.Validate as Validate exposing (..)
+import Form.Validate as Validate exposing (Validation)
import Validation
type alias Model =
@@ -26,10 +27,10 @@ init =
}
initForm : Form String AddIncome
-initForm = Form.initial [] validate
+initForm = Form.initial [] validation
-validate : Validation String AddIncome
-validate =
- form2 AddIncome
- (get "amount" (int `andThen` (minInt 1)))
- (get "date" Validation.date)
+validation : Validation String AddIncome
+validation =
+ Validate.map2 AddIncome
+ (Validate.field "amount" (Validate.int |> Validate.andThen (Validate.minInt 1)))
+ (Validate.field "date" Validation.date)
diff --git a/src/client/elm/LoggedIn/Income/Update.elm b/src/client/elm/LoggedIn/Income/Update.elm
index ec6a0c1..0023c76 100644
--- a/src/client/elm/LoggedIn/Income/Update.elm
+++ b/src/client/elm/LoggedIn/Income/Update.elm
@@ -6,19 +6,19 @@ import Form exposing (Form)
import LoggedData exposing (LoggedData)
-import LoggedIn.Income.Model as IncomeModel
-import LoggedIn.Income.Msg as IncomeMsg
+import LoggedIn.Income.Model as Income
+import LoggedIn.Income.Msg as Income
-update : LoggedData -> IncomeMsg.Msg -> IncomeModel.Model -> (IncomeModel.Model, Cmd IncomeMsg.Msg)
+update : LoggedData -> Income.Msg -> Income.Model -> (Income.Model, Cmd Income.Msg)
update loggedData msg model =
case msg of
- IncomeMsg.NoOp ->
+ Income.NoOp ->
( model
, Cmd.none
)
- IncomeMsg.AddIncomeMsg formMsg ->
- ( { model | addIncome = Form.update formMsg model.addIncome }
+ Income.AddIncomeMsg formMsg ->
+ ( { model | addIncome = Form.update Income.validation formMsg model.addIncome }
, Cmd.none
)
diff --git a/src/client/elm/LoggedIn/Income/View.elm b/src/client/elm/LoggedIn/Income/View.elm
index 2c5bcaf..00a1646 100644
--- a/src/client/elm/LoggedIn/Income/View.elm
+++ b/src/client/elm/LoggedIn/Income/View.elm
@@ -12,7 +12,6 @@ import FontAwesome
import Html exposing (..)
import Html.Events exposing (..)
import Html.Attributes exposing (..)
-import Html.App as Html
import Form exposing (Form)
import View.Form as Form
@@ -45,19 +44,21 @@ 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 ""
- , div
- [ class "textual monthlyNetIncomes" ]
- [ h1 [] [ text <| getMessage loggedData.translations "MonthlyNetIncomes" ]
- , AddIncome.button
- "addIncome"
- loggedData
- (AddIncome.initialAdd loggedData.translations (Date.fromTime loggedData.currentTime))
- "AddIncome"
- (text (getMessage loggedData.translations "AddIncome"))
- Nothing
+ [ div
+ [ class "withMargin" ]
+ [ case useIncomesFrom loggedData.users loggedData.incomes loggedData.payments of
+ Just since -> cumulativeIncomesView loggedData since
+ Nothing -> text ""
+ , div
+ [ class "titleButton" ]
+ [ h1 [] [ text <| getMessage loggedData.translations "MonthlyNetIncomes" ]
+ , AddIncome.button
+ loggedData
+ (AddIncome.initialAdd loggedData.translations (Date.fromTime loggedData.currentTime))
+ "AddIncome"
+ (text (getMessage loggedData.translations "AddIncome"))
+ Nothing
+ ]
]
, Table.view loggedData incomeModel
]
@@ -66,7 +67,7 @@ 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] loggedData.translations "CumulativeIncomesSince" ]
, ul
[]
@@ -74,7 +75,7 @@ cumulativeIncomesView loggedData since =
|> List.map (\(userId, user) ->
(user.name, userCumulativeIncomeSince loggedData.currentTime since loggedData.incomes userId)
)
- |> List.sortBy snd
+ |> List.sortBy Tuple.second
|> List.map (\(userName, cumulativeIncome) ->
li
[]
diff --git a/src/client/elm/LoggedIn/Income/View/Table.elm b/src/client/elm/LoggedIn/Income/View/Table.elm
index dcf6d78..aa5e392 100644
--- a/src/client/elm/LoggedIn/Income/View/Table.elm
+++ b/src/client/elm/LoggedIn/Income/View/Table.elm
@@ -38,7 +38,7 @@ view loggedData incomeModel =
let incomes =
loggedData.incomes
|> Dict.toList
- |> List.sortBy (.time << snd)
+ |> List.sortBy (.time << Tuple.second)
|> List.reverse
in div
[ class "table" ]
@@ -49,7 +49,7 @@ view loggedData incomeModel =
then
div
[ class "emptyTableMsg" ]
- [ text <| getMessage loggedData.translations "NoPayment" ]
+ [ text <| getMessage loggedData.translations "NoIncome" ]
else
text ""
]
@@ -87,7 +87,6 @@ paymentLine loggedData incomeModel (incomeId, income) =
[ class "cell button" ]
[ let currentDate = Date.fromTime loggedData.currentTime
in AddIncome.button
- ""
loggedData
(AddIncome.initialClone loggedData.translations currentDate income)
"CloneIncome"
@@ -101,7 +100,6 @@ paymentLine loggedData incomeModel (incomeId, income) =
text ""
else
AddIncome.button
- ""
loggedData
(AddIncome.initialEdit loggedData.translations incomeId income)
"EditIncome"