blob: 9d246ef385918ec724812690c0f4a6706f44b59c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
module View.Payments.Add
( addPayment
) where
import Html as H exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Reads exposing (readInt)
import Result exposing (..)
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 =
H.form
[ class "add"
, onSubmitPrevDefault serverCommunications.address
<| case readInt cost of
Ok number -> SC.AddPayment name number
Err _ -> SC.NoCommunication
]
[ div
[ class "name" ]
[ label
[ for "nameInput" ]
[ text "Name" ]
, input
[ id "nameInput"
, value name
, on "input" targetValue (Signal.message actions.address << UpdatePayment << UpdateName)
]
[]
]
, div
[ class "cost" ]
[ label
[ for "costInput" ]
[ text "Cost" ]
, input
[ id "costInput"
, value cost
, on "input" targetValue (Signal.message actions.address << UpdatePayment << UpdateCost)
]
[]
, button
[ type' "submit" ]
[ text "Add" ]
]
]
|