diff options
author | Joris | 2015-09-04 23:13:48 +0200 |
---|---|---|
committer | Joris | 2015-09-04 23:13:48 +0200 |
commit | c876fd8c2f1aac2c3fe10c2b7de734f3ef71b71f (patch) | |
tree | 23ff6a85ee81a0cc8419b7c1acbec0a33bd02fab /src/client/View | |
parent | c1f44a5890fbb26faf6f17c676662ea1bd495f2e (diff) |
Paging model works with both payments addition and deletion
Diffstat (limited to 'src/client/View')
-rw-r--r-- | src/client/View/Payments.elm | 2 | ||||
-rw-r--r-- | src/client/View/Payments/Add.elm | 91 | ||||
-rw-r--r-- | src/client/View/Payments/Table.elm | 2 |
3 files changed, 52 insertions, 43 deletions
diff --git a/src/client/View/Payments.elm b/src/client/View/Payments.elm index 3c9c09d..256e686 100644 --- a/src/client/View/Payments.elm +++ b/src/client/View/Payments.elm @@ -19,7 +19,7 @@ renderPayments model paymentView = div [ class "payments" ] [ exceedingPayers model paymentView - , addPayment model paymentView.add + , addPayment model paymentView , paymentsTable model paymentView , paymentsPaging paymentView ] diff --git a/src/client/View/Payments/Add.elm b/src/client/View/Payments/Add.elm index 941f6b8..115fed2 100644 --- a/src/client/View/Payments/Add.elm +++ b/src/client/View/Payments/Add.elm @@ -17,6 +17,7 @@ import Update.Payment.Add exposing (..) import Model exposing (Model) import Model.View.Payment.Add exposing (..) import Model.Translations exposing (getMessage) +import Model.View.PaymentView exposing (PaymentView) import View.Events exposing (onSubmitPrevDefault) import View.Icon exposing (renderIcon) @@ -24,53 +25,61 @@ import View.Icon exposing (renderIcon) import Utils.Maybe exposing (isJust) import Utils.Either exposing (toMaybeError) -addPayment : Model -> AddPayment -> Html -addPayment model addPayment = +addPayment : Model -> PaymentView -> Html +addPayment model paymentView = H.form [ class "add" - , case (validateName addPayment.name model.translations, validateCost addPayment.cost model.translations) of + , case (validateName paymentView.add.name model.translations, validateCost paymentView.add.cost model.translations) of (Ok name, Ok cost) -> - onSubmitPrevDefault serverCommunications.address (SC.AddPayment name cost) + onSubmitPrevDefault serverCommunications.address (SC.AddPayment paymentView.userName name cost) (resName, resCost) -> onSubmitPrevDefault actions.address (UpdatePayment <| UpdateAdd <| AddError (toMaybeError resName) (toMaybeError resCost)) ] - [ div - [ class ("name " ++ (if isJust addPayment.nameError then "error" else "")) ] - [ input - [ id "nameInput" - , value addPayment.name - , on "input" targetValue (Signal.message actions.address << UpdatePayment << UpdateAdd << UpdateName) - , maxlength 20 - ] - [] - , label - [ for "nameInput" ] - [ renderIcon "shopping-cart" ] - , case addPayment.nameError of - Just error -> - div [ class "errorMessage" ] [ text error ] - Nothing -> - text "" + [ addPaymentName paymentView.add + , addPaymentCost model paymentView.add + , button + [ type' "submit" ] + [ text (getMessage "Add" model.translations)] + ] + +addPaymentName : AddPayment -> Html +addPaymentName addPayment = + div + [ class ("name " ++ (if isJust addPayment.nameError then "error" else "")) ] + [ input + [ id "nameInput" + , value addPayment.name + , on "input" targetValue (Signal.message actions.address << UpdatePayment << UpdateAdd << UpdateName) + , maxlength 20 ] - , div - [ class ("cost " ++ (if isJust addPayment.costError then "error" else "")) ] - [ input - [ id "costInput" - , value addPayment.cost - , on "input" targetValue (Signal.message actions.address << UpdatePayment << UpdateAdd << UpdateCost) - , maxlength 7 - ] - [] - , label - [ for "costInput" ] - [ text (getMessage "MoneySymbol" model.translations) ] - , case addPayment.costError of - Just error -> - div [ class "errorMessage" ] [ text error ] - Nothing -> - text "" + [] + , label + [ for "nameInput" ] + [ renderIcon "shopping-cart" ] + , case addPayment.nameError of + Just error -> + div [ class "errorMessage" ] [ text error ] + Nothing -> + text "" + ] + +addPaymentCost : Model -> AddPayment -> Html +addPaymentCost model addPayment = + div + [ class ("cost " ++ (if isJust addPayment.costError then "error" else "")) ] + [ input + [ id "costInput" + , value addPayment.cost + , on "input" targetValue (Signal.message actions.address << UpdatePayment << UpdateAdd << UpdateCost) + , maxlength 7 ] - , button - [ type' "submit" ] - [ text (getMessage "Add" model.translations)] + [] + , label + [ for "costInput" ] + [ text (getMessage "MoneySymbol" model.translations) ] + , case addPayment.costError of + Just error -> + div [ class "errorMessage" ] [ text error ] + Nothing -> + text "" ] diff --git a/src/client/View/Payments/Table.elm b/src/client/View/Payments/Table.elm index 12b1a46..06bec17 100644 --- a/src/client/View/Payments/Table.elm +++ b/src/client/View/Payments/Table.elm @@ -69,7 +69,7 @@ paymentLine model paymentView (id, payment) = then div [ class "cell remove" - , onClick serverCommunications.address (SC.DeletePayment id) + , onClick serverCommunications.address (SC.DeletePayment id payment.userName payment.cost paymentView.currentPage) ] [ renderIcon "times" ] else |