diff options
Diffstat (limited to 'src/client/View/Payments')
-rw-r--r-- | src/client/View/Payments/Add.elm | 6 | ||||
-rw-r--r-- | src/client/View/Payments/Monthly.elm | 27 | ||||
-rw-r--r-- | src/client/View/Payments/Table.elm | 4 |
3 files changed, 25 insertions, 12 deletions
diff --git a/src/client/View/Payments/Add.elm b/src/client/View/Payments/Add.elm index 21406b2..deffb95 100644 --- a/src/client/View/Payments/Add.elm +++ b/src/client/View/Payments/Add.elm @@ -31,7 +31,11 @@ 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 loggedView.add.frequency) + let action = + case loggedView.add.frequency of + Punctual -> SC.AddPayment loggedView.me name cost + Monthly -> SC.AddMonthlyPayment name cost + in onSubmitPrevDefault serverCommunications.address action (resName, resCost) -> onSubmitPrevDefault actions.address (UpdateLoggedView <| UpdateAdd <| AddError (toMaybeError resName) (toMaybeError resCost)) ] diff --git a/src/client/View/Payments/Monthly.elm b/src/client/View/Payments/Monthly.elm index e115dbf..944314c 100644 --- a/src/client/View/Payments/Monthly.elm +++ b/src/client/View/Payments/Monthly.elm @@ -14,7 +14,9 @@ import Model exposing (Model) import Model.View.Payment.Monthly exposing (Monthly) import Model.Payment exposing (Payments, Payment) import Model.View.LoggedView exposing (LoggedView) -import Model.Translations exposing (getMessage, getVarMessage) +import Model.Translations exposing (getMessage, getParamMessage) + +import ServerCommunication as SC exposing (serverCommunications) import View.Icon exposing (renderIcon) @@ -28,7 +30,7 @@ monthlyPayments model loggedView = div [ class ("monthlyPayments" ++ if monthly.visibleDetail then " detail" else "") ] [ monthlyCount model monthly - , if monthly.visibleDetail then paymentsTable model monthly else text "" + , if monthly.visibleDetail then paymentsTable model loggedView monthly else text "" ] monthlyCount : Model -> Monthly -> Html @@ -39,7 +41,7 @@ monthlyCount model monthly = [ class "count" , onClick actions.address (UpdateLoggedView << UpdateMonthly <| ToggleDetail) ] - [ text (getVarMessage [toString count] key model.translations) + [ text (getParamMessage [toString count] key model.translations) , div [ class "expand" ] [ if monthly.visibleDetail @@ -48,16 +50,23 @@ monthlyCount model monthly = ] ] -paymentsTable : Model -> Monthly -> Html -paymentsTable model monthly = +paymentsTable : Model -> LoggedView -> Monthly -> Html +paymentsTable model loggedView monthly = div [ class "table" ] - ( List.map (paymentLine model) monthly.payments ) + ( List.map (paymentLine model loggedView) monthly.payments ) -paymentLine : Model -> Payment -> Html -paymentLine model payment = +paymentLine : Model -> LoggedView -> Payment -> Html +paymentLine model loggedView payment = a - [ class "row" ] + [ class ("row" ++ (if loggedView.paymentEdition == Just payment.id then " edition" else "")) + , onClick actions.address (UpdateLoggedView (ToggleEdit payment.id)) + ] [ div [ class "cell" ] [ text (payment.name) ] , div [ class "cell" ] [ text (toString payment.cost ++ " " ++ getMessage "MoneySymbol" model.translations) ] + , div + [ class "cell delete" + , onClick serverCommunications.address (SC.DeleteMonthlyPayment payment.id) + ] + [ renderIcon "times" ] ] diff --git a/src/client/View/Payments/Table.elm b/src/client/View/Payments/Table.elm index 4642f65..1646186 100644 --- a/src/client/View/Payments/Table.elm +++ b/src/client/View/Payments/Table.elm @@ -53,7 +53,7 @@ paymentLines model loggedView = paymentLine : Model -> LoggedView -> Payment -> Html paymentLine model loggedView payment = a - [ class ("row " ++ (if loggedView.paymentEdition == Just payment.id then "edition" else "")) + [ class ("row" ++ (if loggedView.paymentEdition == Just payment.id then " edition" else "")) , onClick actions.address (UpdateLoggedView (ToggleEdit payment.id)) ] [ div [ class "cell category" ] [ text payment.name ] @@ -77,7 +77,7 @@ paymentLine model loggedView payment = , if loggedView.me == payment.userId then div - [ class "cell remove" + [ class "cell delete" , onClick serverCommunications.address (SC.DeletePayment payment.id payment.userId payment.cost loggedView.currentPage) ] [ renderIcon "times" ] |