aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm')
-rw-r--r--src/client/elm/LoggedIn/Home/View/Paging.elm13
-rw-r--r--src/client/elm/LoggedIn/Home/View/Table.elm6
-rw-r--r--src/client/elm/LoggedIn/Stat/View.elm34
-rw-r--r--src/client/elm/Utils/List.elm4
4 files changed, 42 insertions, 15 deletions
diff --git a/src/client/elm/LoggedIn/Home/View/Paging.elm b/src/client/elm/LoggedIn/Home/View/Paging.elm
index b8d7db9..9166d23 100644
--- a/src/client/elm/LoggedIn/Home/View/Paging.elm
+++ b/src/client/elm/LoggedIn/Home/View/Paging.elm
@@ -2,7 +2,7 @@ module LoggedIn.Home.View.Paging exposing
( paymentsPaging
)
-import Color
+import Color exposing (Color)
import FontAwesome
@@ -60,7 +60,7 @@ firstPage homeModel =
]
, onClick (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| 1)
]
- [ FontAwesome.fast_backward Color.darkGrey 20 ]
+ [ FontAwesome.fast_backward grey 20 ]
previousPage : HomeModel.Model -> Html Msg
previousPage homeModel =
@@ -71,7 +71,7 @@ previousPage homeModel =
then (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| homeModel.currentPage - 1)
else Msg.NoOp
]
- [ FontAwesome.backward Color.darkGrey 20 ]
+ [ FontAwesome.backward grey 20 ]
nextPage : HomeModel.Model -> Int -> Html Msg
nextPage homeModel maxPage =
@@ -82,7 +82,7 @@ nextPage homeModel maxPage =
then (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| homeModel.currentPage + 1)
else Msg.NoOp
]
- [ FontAwesome.forward Color.darkGrey 20 ]
+ [ FontAwesome.forward grey 20 ]
lastPage : HomeModel.Model -> Int -> Html Msg
lastPage homeModel maxPage =
@@ -90,7 +90,7 @@ lastPage homeModel maxPage =
[ class "page"
, onClick (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| maxPage)
]
- [ FontAwesome.fast_forward Color.darkGrey 20 ]
+ [ FontAwesome.fast_forward grey 20 ]
paymentsPage : HomeModel.Model -> Int -> Html Msg
paymentsPage homeModel page =
@@ -106,3 +106,6 @@ paymentsPage homeModel page =
else Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| page
]
[ text (toString page) ]
+
+grey : Color
+grey = Color.greyscale 0.35
diff --git a/src/client/elm/LoggedIn/Home/View/Table.elm b/src/client/elm/LoggedIn/Home/View/Table.elm
index 7c8a800..a03faa2 100644
--- a/src/client/elm/LoggedIn/Home/View/Table.elm
+++ b/src/client/elm/LoggedIn/Home/View/Table.elm
@@ -37,10 +37,10 @@ headerLine : LoggedData -> Html Msg
headerLine loggedData =
div
[ class "header" ]
- [ div [ class "cell category" ] [ FontAwesome.shopping_cart Color.white 25 ]
+ [ div [ class "cell category" ] [ FontAwesome.shopping_cart Color.white 28 ]
, div [ class "cell cost" ] [ text loggedData.conf.currency ]
- , div [ class "cell user" ] [ FontAwesome.user Color.white 25 ]
- , div [ class "cell date" ] [ FontAwesome.calendar Color.white 25 ]
+ , div [ class "cell user" ] [ FontAwesome.user Color.white 28 ]
+ , div [ class "cell date" ] [ FontAwesome.calendar Color.white 28 ]
, div [ class "cell" ] []
]
diff --git a/src/client/elm/LoggedIn/Stat/View.elm b/src/client/elm/LoggedIn/Stat/View.elm
index 77a32a0..bb1ec84 100644
--- a/src/client/elm/LoggedIn/Stat/View.elm
+++ b/src/client/elm/LoggedIn/Stat/View.elm
@@ -15,7 +15,7 @@ import Msg exposing (Msg)
import Model.Payment as Payment exposing (Payments)
import Model.Conf exposing (Conf)
-import Model.Translations exposing (getMessage)
+import Model.Translations exposing (getMessage, getParamMessage)
import LoggedIn.View.Format as Format
import LoggedIn.View.Date as Date
@@ -24,6 +24,7 @@ import View.Plural exposing (plural)
import LoggedIn.View.Format as Format
import Utils.Tuple as Tuple
+import Utils.List as List
view : LoggedData -> Html Msg
view loggedData =
@@ -74,12 +75,31 @@ totalPayments loggedData =
monthsDetail : LoggedData -> Html Msg
monthsDetail loggedData =
- ul
- []
- ( Payment.punctual loggedData.payments
- |> Payment.groupAndSortByMonth
- |> List.map (monthDetail loggedData)
- )
+ let paymentsByMonth =
+ loggedData.payments
+ |> Payment.punctual
+ |> Payment.groupAndSortByMonth
+ monthPaymentMean =
+ paymentsByMonth
+ |> List.filter (\((month, year), _) ->
+ let currentDate = Date.fromTime loggedData.currentTime
+ in not (Date.month currentDate == month && Date.year currentDate == year)
+ )
+ |> List.map (List.sum << List.map .cost << snd)
+ |> List.mean
+ in div
+ []
+ [ div
+ [ class "mean" ]
+ [ text (getParamMessage [ Format.price loggedData.conf monthPaymentMean ] "Mean" loggedData.translations)
+ ]
+ , ul
+ []
+ ( Payment.punctual loggedData.payments
+ |> Payment.groupAndSortByMonth
+ |> List.map (monthDetail loggedData)
+ )
+ ]
monthDetail : LoggedData -> ((Month, Int), Payments) -> Html Msg
monthDetail loggedData ((month, year), payments) =
diff --git a/src/client/elm/Utils/List.elm b/src/client/elm/Utils/List.elm
index 4886418..cc57d9f 100644
--- a/src/client/elm/Utils/List.elm
+++ b/src/client/elm/Utils/List.elm
@@ -1,5 +1,6 @@
module Utils.List exposing
( groupBy
+ , mean
)
import Dict
@@ -11,3 +12,6 @@ groupBy f xs =
in Dict.insert (f item) (item :: groupItems) dict
in List.foldr addItem Dict.empty xs
|> Dict.toList
+
+mean : List Int -> Int
+mean xs = (List.sum xs) // (List.length xs)