aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/View/Date.elm32
-rw-r--r--src/client/View/Payments.elm2
-rw-r--r--src/client/View/Payments/Table.elm26
3 files changed, 44 insertions, 16 deletions
diff --git a/src/client/View/Date.elm b/src/client/View/Date.elm
new file mode 100644
index 0000000..c96e99e
--- /dev/null
+++ b/src/client/View/Date.elm
@@ -0,0 +1,32 @@
+module View.Date
+ ( renderDate
+ ) where
+
+import Date exposing (..)
+
+import Model.Translations exposing (..)
+
+renderDate : Date -> Translations -> String
+renderDate date translations =
+ let params =
+ [ toString (Date.day date)
+ , (getMessage (getMonthKey (Date.month date)) translations)
+ , toString (Date.year date)
+ ]
+ in getVarMessage params "Date" translations
+
+getMonthKey : Month -> String
+getMonthKey month =
+ case month of
+ Jan -> "January"
+ Feb -> "February"
+ Mar -> "March"
+ Apr -> "April"
+ May -> "May"
+ Jun -> "June"
+ Jul -> "July"
+ Aug -> "August"
+ Sep -> "September"
+ Oct -> "October"
+ Nov -> "November"
+ Dec -> "December"
diff --git a/src/client/View/Payments.elm b/src/client/View/Payments.elm
index ba930b5..c79b9c5 100644
--- a/src/client/View/Payments.elm
+++ b/src/client/View/Payments.elm
@@ -17,5 +17,5 @@ renderPayments model paymentView =
div
[ class "payments" ]
[ addPayment model paymentView.add
- , paymentsTable paymentView.payments
+ , paymentsTable model paymentView.payments
]
diff --git a/src/client/View/Payments/Table.elm b/src/client/View/Payments/Table.elm
index 847c620..e5c1a9a 100644
--- a/src/client/View/Payments/Table.elm
+++ b/src/client/View/Payments/Table.elm
@@ -10,12 +10,14 @@ import Date exposing (Date)
import String exposing (append)
+import Model exposing (Model)
import Model.Payment exposing (Payments, Payment)
import View.Icon exposing (renderIcon)
+import View.Date exposing (renderDate)
-paymentsTable : Payments -> Html
-paymentsTable payments =
+paymentsTable : Model -> Payments -> Html
+paymentsTable model payments =
table
[]
([ tr
@@ -25,27 +27,21 @@ paymentsTable payments =
, th [ class "user" ] [ renderIcon "user" ]
, th [ class "date" ] [ renderIcon "calendar" ]
]
- ] ++ (paymentLines payments))
+ ] ++ (paymentLines model payments))
-paymentLines : Payments -> List Html
-paymentLines payments =
+paymentLines : Model -> Payments -> List Html
+paymentLines model payments =
payments
|> List.sortBy (Date.toTime << .creation)
|> List.reverse
- |> List.map paymentLine
+ |> List.map (paymentLine model)
-paymentLine : Payment -> Html
-paymentLine payment =
+paymentLine : Model -> Payment -> Html
+paymentLine model payment =
tr
[]
[ td [] [ text payment.name ]
, td [] [ text ((toString payment.cost) ++ " €") ]
, td [] [ text payment.userName ]
- , td [] [ text (renderDate payment.creation) ]
+ , td [] [ text (renderDate payment.creation model.translations) ]
]
-
-renderDate : Date -> String
-renderDate date =
- toString (Date.day date)
- |> flip append (" " ++ (toString (Date.month date)) ++ ".")
- |> flip append (" " ++ (toString (Date.year date)))