diff options
author | Joris Guyonvarch | 2015-07-21 23:25:58 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-07-21 23:25:58 +0200 |
commit | 2a53fe50c62d4b7aec0f422998c743f68aa523c1 (patch) | |
tree | ad32464c99668b477c4006146ec218c947bc9c8f /src/client/View/Payments | |
parent | a271d6034bc4cc631a64476d25d21c83a701fa39 (diff) |
Adding the payment without reloading the page
Diffstat (limited to 'src/client/View/Payments')
-rw-r--r-- | src/client/View/Payments/Add.elm | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/client/View/Payments/Add.elm b/src/client/View/Payments/Add.elm index f2230be..32010ef 100644 --- a/src/client/View/Payments/Add.elm +++ b/src/client/View/Payments/Add.elm @@ -2,20 +2,28 @@ module View.Payments.Add ( addPayment ) where -import Html exposing (..) +import Html as H exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) +import Reads exposing (readInt) +import Result exposing (..) -import ServerCommunication as SC -import ServerCommunication exposing (serverCommunications) +import ServerCommunication as SC exposing (serverCommunications) import Update exposing (..) import Update.Payment exposing (..) +import View.Events exposing (onSubmitPrevDefault) + addPayment : String -> String -> Html addPayment name cost = - div - [ class "add" ] + H.form + [ class "add" + , onSubmitPrevDefault serverCommunications.address + <| case readInt cost of + Ok number -> SC.AddPayment name number + Err _ -> SC.NoCommunication + ] [ text "Name" , input [ value name @@ -29,6 +37,6 @@ addPayment name cost = ] [] , button - [ onClick serverCommunications.address (SC.AddPayment name cost) ] + [ type' "submit" ] [ text "Add" ] ] |