aboutsummaryrefslogtreecommitdiff
path: root/src/client/View
diff options
context:
space:
mode:
authorJoris2015-09-06 00:05:50 +0200
committerJoris2015-09-06 00:05:50 +0200
commit24633871359ec9fbd63fdfebf79a6351b2792f77 (patch)
treea87c8a964a3c5114da13e622c604cf99ab905a06 /src/client/View
parent8c328987901973cd0ffd2e03cae547717ebbbc67 (diff)
Can add monthly payments, not visible at the moment though, just the count is printed
Diffstat (limited to 'src/client/View')
-rw-r--r--src/client/View/Payments.elm2
-rw-r--r--src/client/View/Payments/Add.elm2
-rw-r--r--src/client/View/Payments/Monthly.elm24
-rw-r--r--src/client/View/Payments/Table.elm13
4 files changed, 33 insertions, 8 deletions
diff --git a/src/client/View/Payments.elm b/src/client/View/Payments.elm
index b51c9a0..ac19df7 100644
--- a/src/client/View/Payments.elm
+++ b/src/client/View/Payments.elm
@@ -11,6 +11,7 @@ import Model.View.LoggedView exposing (LoggedView)
import View.Payments.ExceedingPayer exposing (exceedingPayers)
import View.Payments.Add exposing (addPayment)
+import View.Payments.Monthly exposing (monthlyPayments)
import View.Payments.Table exposing (paymentsTable)
import View.Payments.Paging exposing (paymentsPaging)
@@ -20,6 +21,7 @@ renderPayments model loggedView =
[ class "payments" ]
[ exceedingPayers model loggedView
, addPayment model loggedView
+ , monthlyPayments model loggedView
, paymentsTable model loggedView
, paymentsPaging loggedView
]
diff --git a/src/client/View/Payments/Add.elm b/src/client/View/Payments/Add.elm
index 085b16d..a22c1f1 100644
--- a/src/client/View/Payments/Add.elm
+++ b/src/client/View/Payments/Add.elm
@@ -31,7 +31,7 @@ addPayment model loggedView =
[ class "add"
, case (validateName loggedView.add.name model.translations, validateCost loggedView.add.cost model.translations) of
(Ok name, Ok cost) ->
- onSubmitPrevDefault serverCommunications.address (SC.AddPayment loggedView.me name cost)
+ onSubmitPrevDefault serverCommunications.address (SC.AddPayment loggedView.me name cost loggedView.add.frequency)
(resName, resCost) ->
onSubmitPrevDefault actions.address (UpdatePayment <| UpdateAdd <| AddError (toMaybeError resName) (toMaybeError resCost))
]
diff --git a/src/client/View/Payments/Monthly.elm b/src/client/View/Payments/Monthly.elm
new file mode 100644
index 0000000..366af92
--- /dev/null
+++ b/src/client/View/Payments/Monthly.elm
@@ -0,0 +1,24 @@
+module View.Payments.Monthly
+ ( monthlyPayments
+ ) where
+
+import Html exposing (..)
+import Html.Attributes exposing (..)
+import Html.Events exposing (..)
+
+import Model exposing (Model)
+import Model.Payment exposing (Payments)
+import Model.View.LoggedView exposing (LoggedView)
+import Model.Translations exposing (getVarMessage)
+
+monthlyPayments : Model -> LoggedView -> Html
+monthlyPayments model loggedView =
+ div
+ [ class "monthlyPayments" ]
+ [ monthlyCount model loggedView.monthlyPayments ]
+
+monthlyCount : Model -> Payments -> Html
+monthlyCount model monthlyPayments =
+ let count = List.length monthlyPayments
+ key = if count > 1 then "PluralMonthlyCount" else "SingularMonthlyCount"
+ in text (getVarMessage [toString count] key model.translations)
diff --git a/src/client/View/Payments/Table.elm b/src/client/View/Payments/Table.elm
index 5374c44..4a1ed50 100644
--- a/src/client/View/Payments/Table.elm
+++ b/src/client/View/Payments/Table.elm
@@ -43,16 +43,15 @@ paymentsTable model loggedView =
paymentLines : Model -> LoggedView -> List Html
paymentLines model loggedView =
loggedView.payments
- |> Dict.toList
- |> List.sortBy (\(_, payment) -> Date.toTime payment.creation)
+ |> List.sortBy (Date.toTime << .creation)
|> List.reverse
|> List.map (paymentLine model loggedView)
-paymentLine : Model -> LoggedView -> PaymentWithId -> Html
-paymentLine model loggedView (id, payment) =
+paymentLine : Model -> LoggedView -> Payment -> Html
+paymentLine model loggedView payment =
a
- [ class ("row " ++ (if loggedView.edition == Just id then "edition" else ""))
- , onClick actions.address (UpdatePayment (ToggleEdit id))
+ [ class ("row " ++ (if loggedView.edition == Just payment.id then "edition" else ""))
+ , onClick actions.address (UpdatePayment (ToggleEdit payment.id))
]
[ div [ class "cell category" ] [ text payment.name ]
, div [ class "cell cost" ] [ text ((toString payment.cost) ++ " " ++ (getMessage "MoneySymbol" model.translations)) ]
@@ -76,7 +75,7 @@ paymentLine model loggedView (id, payment) =
then
div
[ class "cell remove"
- , onClick serverCommunications.address (SC.DeletePayment id payment.userId payment.cost loggedView.currentPage)
+ , onClick serverCommunications.address (SC.DeletePayment payment.id payment.userId payment.cost loggedView.currentPage)
]
[ renderIcon "times" ]
else