aboutsummaryrefslogtreecommitdiff
path: root/src/client/View
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/View')
-rw-r--r--src/client/View/Payments.elm2
-rw-r--r--src/client/View/Payments/Table.elm55
2 files changed, 32 insertions, 25 deletions
diff --git a/src/client/View/Payments.elm b/src/client/View/Payments.elm
index c79b9c5..29ab481 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 model paymentView.payments
+ , paymentsTable model paymentView
]
diff --git a/src/client/View/Payments/Table.elm b/src/client/View/Payments/Table.elm
index e5c1a9a..7fa2ff1 100644
--- a/src/client/View/Payments/Table.elm
+++ b/src/client/View/Payments/Table.elm
@@ -4,6 +4,7 @@ module View.Payments.Table
import Html exposing (..)
import Html.Attributes exposing (..)
+import Html.Events exposing (..)
import Date
import Date exposing (Date)
@@ -12,36 +13,42 @@ import String exposing (append)
import Model exposing (Model)
import Model.Payment exposing (Payments, Payment)
+import Model.View.PaymentView exposing (PaymentView)
+
+import Update exposing (..)
+import Update.Payment exposing (..)
import View.Icon exposing (renderIcon)
import View.Date exposing (renderDate)
-paymentsTable : Model -> Payments -> Html
-paymentsTable model payments =
- table
- []
- ([ tr
- []
- [ th [ class "category" ] [ renderIcon "shopping-cart" ]
- , th [ class "cost" ] [ renderIcon "euro" ]
- , th [ class "user" ] [ renderIcon "user" ]
- , th [ class "date" ] [ renderIcon "calendar" ]
+paymentsTable : Model -> PaymentView -> Html
+paymentsTable model paymentView =
+ div
+ [ class "table" ]
+ ([ div
+ [ class "header" ]
+ [ div [ class "cell category" ] [ renderIcon "shopping-cart" ]
+ , div [ class "cell cost" ] [ renderIcon "euro" ]
+ , div [ class "cell user" ] [ renderIcon "user" ]
+ , div [ class "cell date" ] [ renderIcon "calendar" ]
]
- ] ++ (paymentLines model payments))
+ ] ++ (paymentLines model paymentView))
-paymentLines : Model -> Payments -> List Html
-paymentLines model payments =
- payments
+paymentLines : Model -> PaymentView -> List Html
+paymentLines model paymentView =
+ paymentView.payments
|> List.sortBy (Date.toTime << .creation)
|> List.reverse
- |> List.map (paymentLine model)
-
-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 model.translations) ]
+ |> List.map (paymentLine model paymentView)
+
+paymentLine : Model -> PaymentView -> Payment -> Html
+paymentLine model paymentView payment =
+ a
+ [ class ("row " ++ (if paymentView.edition == Just payment.id then "edition" else ""))
+ , onClick actions.address (UpdatePayment (ToggleEdit payment.id))
+ ]
+ [ div [ class "cell" ] [ text payment.name ]
+ , div [ class "cell" ] [ text ((toString payment.cost) ++ " €") ]
+ , div [ class "cell" ] [ text payment.userName ]
+ , div [ class "cell" ] [ text (renderDate payment.creation model.translations) ]
]