From d25b857d8317d729995d6aa25db7a83fe92a07ef Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Fri, 14 Aug 2015 09:23:12 +0200 Subject: Translating dates --- src/client/View/Payments/Table.elm | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/client/View/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))) -- cgit v1.2.3