aboutsummaryrefslogtreecommitdiff
path: root/src/client/Update
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-08-01 00:31:36 +0200
committerJoris Guyonvarch2015-08-01 00:31:36 +0200
commitc345f9daa28e0c174b35413addf78df0a793f8c1 (patch)
tree206f1d9aeed76b5c9e6f6abd24c00a50ec6c54fd /src/client/Update
parent043d315c4b15608e04a07cd709e4caf5c3758c61 (diff)
downloadbudget-c345f9daa28e0c174b35413addf78df0a793f8c1.tar.gz
budget-c345f9daa28e0c174b35413addf78df0a793f8c1.tar.bz2
budget-c345f9daa28e0c174b35413addf78df0a793f8c1.zip
Adding error feedbacks when adding a payment
Diffstat (limited to 'src/client/Update')
-rw-r--r--src/client/Update/Payment.elm17
-rw-r--r--src/client/Update/Payment/Add.elm24
2 files changed, 32 insertions, 9 deletions
diff --git a/src/client/Update/Payment.elm b/src/client/Update/Payment.elm
index 136f0f9..2d558fd 100644
--- a/src/client/Update/Payment.elm
+++ b/src/client/Update/Payment.elm
@@ -6,22 +6,22 @@ module Update.Payment
import Date
import Model exposing (Model)
-import Model.View.PaymentView exposing (..)
import Model.Payment exposing (..)
+import Model.View.PaymentView exposing (..)
+import Model.View.Payment.Add exposing (..)
+
+import Update.Payment.Add exposing (..)
type PaymentAction =
- UpdateName String
- | UpdateCost String
+ UpdateAdd AddPaymentAction
| UpdatePayments Payments
| AddPayment String Int
updatePayment : Model -> PaymentAction -> PaymentView -> PaymentView
updatePayment model action paymentView =
case action of
- UpdateName name ->
- { paymentView | name <- name }
- UpdateCost cost ->
- { paymentView | cost <- cost }
+ UpdateAdd addPaymentAction ->
+ { paymentView | add <- updateAddPayment addPaymentAction paymentView.add }
UpdatePayments payments ->
{ paymentView | payments <- payments }
AddPayment name cost ->
@@ -33,6 +33,5 @@ updatePayment model action paymentView =
}
in { paymentView
| payments <- payment :: paymentView.payments
- , name <- ""
- , cost <- ""
+ , add <- initAddPayment
}
diff --git a/src/client/Update/Payment/Add.elm b/src/client/Update/Payment/Add.elm
new file mode 100644
index 0000000..3ccce73
--- /dev/null
+++ b/src/client/Update/Payment/Add.elm
@@ -0,0 +1,24 @@
+module Update.Payment.Add
+ ( AddPaymentAction(..)
+ , updateAddPayment
+ ) where
+
+import Model.View.Payment.Add exposing (AddPayment)
+
+type AddPaymentAction =
+ UpdateName String
+ | UpdateCost String
+ | AddError (Maybe String) (Maybe String)
+
+updateAddPayment : AddPaymentAction -> AddPayment -> AddPayment
+updateAddPayment action addPayment =
+ case action of
+ UpdateName name ->
+ { addPayment | name <- name }
+ UpdateCost cost ->
+ { addPayment | cost <- cost }
+ AddError nameError costError ->
+ { addPayment
+ | nameError <- nameError
+ , costError <- costError
+ }