aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/Home/AddPayment
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/LoggedIn/Home/AddPayment')
-rw-r--r--src/client/elm/LoggedIn/Home/AddPayment/Model.elm4
-rw-r--r--src/client/elm/LoggedIn/Home/AddPayment/Msg.elm (renamed from src/client/elm/LoggedIn/Home/AddPayment/Action.elm)8
-rw-r--r--src/client/elm/LoggedIn/Home/AddPayment/Update.elm26
-rw-r--r--src/client/elm/LoggedIn/Home/AddPayment/View.elm36
4 files changed, 37 insertions, 37 deletions
diff --git a/src/client/elm/LoggedIn/Home/AddPayment/Model.elm b/src/client/elm/LoggedIn/Home/AddPayment/Model.elm
index 19933fd..b656077 100644
--- a/src/client/elm/LoggedIn/Home/AddPayment/Model.elm
+++ b/src/client/elm/LoggedIn/Home/AddPayment/Model.elm
@@ -1,7 +1,7 @@
-module LoggedIn.Home.AddPayment.Model
+module LoggedIn.Home.AddPayment.Model exposing
( Model
, init
- ) where
+ )
import Result as Result exposing (Result(..))
import Json.Decode exposing ((:=))
diff --git a/src/client/elm/LoggedIn/Home/AddPayment/Action.elm b/src/client/elm/LoggedIn/Home/AddPayment/Msg.elm
index a692b15..53e6e26 100644
--- a/src/client/elm/LoggedIn/Home/AddPayment/Action.elm
+++ b/src/client/elm/LoggedIn/Home/AddPayment/Msg.elm
@@ -1,10 +1,10 @@
-module LoggedIn.Home.AddPayment.Action
- ( Action(..)
- ) where
+module LoggedIn.Home.AddPayment.Msg exposing
+ ( Msg(..)
+ )
import Model.Payment exposing (Frequency)
-type Action =
+type Msg =
NoOp
| Init Frequency
| UpdateName String
diff --git a/src/client/elm/LoggedIn/Home/AddPayment/Update.elm b/src/client/elm/LoggedIn/Home/AddPayment/Update.elm
index 7f5fb0a..46b3786 100644
--- a/src/client/elm/LoggedIn/Home/AddPayment/Update.elm
+++ b/src/client/elm/LoggedIn/Home/AddPayment/Update.elm
@@ -1,49 +1,49 @@
-module LoggedIn.Home.AddPayment.Update
+module LoggedIn.Home.AddPayment.Update exposing
( update
, addPaymentError
- ) where
+ )
import Maybe
import Json.Decode as Json exposing ((:=))
-import LoggedIn.Home.AddPayment.Action as AddPaymentAction
+import LoggedIn.Home.AddPayment.Msg as AddPaymentMsg
import LoggedIn.Home.AddPayment.Model as AddPaymentModel
import Model.Translations exposing (Translations, getMessage)
import Model.Payment exposing (Frequency(..))
-update : AddPaymentAction.Action -> AddPaymentModel.Model -> AddPaymentModel.Model
+update : AddPaymentMsg.Msg -> AddPaymentModel.Model -> AddPaymentModel.Model
update action addPayment =
case action of
- AddPaymentAction.NoOp ->
+ AddPaymentMsg.NoOp ->
addPayment
- AddPaymentAction.Init frequency ->
+ AddPaymentMsg.Init frequency ->
AddPaymentModel.init frequency
- AddPaymentAction.UpdateName name ->
+ AddPaymentMsg.UpdateName name ->
{ addPayment | name = name }
- AddPaymentAction.UpdateCost cost ->
+ AddPaymentMsg.UpdateCost cost ->
{ addPayment | cost = cost }
- AddPaymentAction.AddError nameError costError ->
+ AddPaymentMsg.AddError nameError costError ->
{ addPayment
| nameError = nameError
, costError = costError
, waitingServer = False
}
- AddPaymentAction.ToggleFrequency ->
+ AddPaymentMsg.ToggleFrequency ->
{ addPayment
| frequency = if addPayment.frequency == Punctual then Monthly else Punctual
}
- AddPaymentAction.WaitingServer ->
+ AddPaymentMsg.WaitingServer ->
{ addPayment | waitingServer = True }
-addPaymentError : Translations -> String -> Maybe AddPaymentAction.Action
+addPaymentError : Translations -> String -> Maybe AddPaymentMsg.Msg
addPaymentError translations jsonErr =
let decoder =
Json.object2 (,)
@@ -53,6 +53,6 @@ addPaymentError translations jsonErr =
Err _ ->
Nothing
Ok (mbNameKey, mbCostKey) ->
- Just <| AddPaymentAction.AddError
+ Just <| AddPaymentMsg.AddError
(Maybe.map (flip getMessage translations) mbNameKey)
(Maybe.map (flip getMessage translations) mbCostKey)
diff --git a/src/client/elm/LoggedIn/Home/AddPayment/View.elm b/src/client/elm/LoggedIn/Home/AddPayment/View.elm
index 96f3a6a..d97f3ca 100644
--- a/src/client/elm/LoggedIn/Home/AddPayment/View.elm
+++ b/src/client/elm/LoggedIn/Home/AddPayment/View.elm
@@ -1,44 +1,44 @@
-module LoggedIn.Home.AddPayment.View
+module LoggedIn.Home.AddPayment.View exposing
( view
- ) where
+ )
import Result exposing (..)
+import Json.Decode as Json
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
-import LoggedIn.Action as LoggedInAction
+import Msg exposing (Msg)
-import LoggedIn.Home.Action as HomeAction
+import LoggedIn.Msg as LoggedInMsg
+
+import LoggedIn.Home.Msg as HomeMsg
import LoggedIn.Home.Model as HomeModel
-import LoggedIn.Home.AddPayment.Action as AddPaymentAction
+import LoggedIn.Home.AddPayment.Msg as AddPaymentMsg
import LoggedIn.Home.AddPayment.Model as AddPaymentModel
import Model.Payment exposing (Frequency(..))
import Model.Translations exposing (getMessage)
import LoggedData exposing (LoggedData)
-import Action
-import Mailbox
-
import View.Events exposing (onSubmitPrevDefault)
import View.Icon exposing (..)
import Utils.Maybe exposing (isJust)
import Utils.Either exposing (toMaybeError)
-view : LoggedData -> HomeModel.Model -> Html
+view : LoggedData -> HomeModel.Model -> Html Msg
view loggedData homeModel =
Html.form
[ let update =
if homeModel.add.waitingServer
then
- Action.NoOp
+ Msg.NoOp
else
- Action.UpdateLoggedIn <| LoggedInAction.AddPayment homeModel.add.name homeModel.add.cost homeModel.add.frequency
- in onSubmitPrevDefault Mailbox.address update
+ Msg.UpdateLoggedIn <| LoggedInMsg.AddPayment homeModel.add.name homeModel.add.cost homeModel.add.frequency
+ in onSubmitPrevDefault update
, class "addPayment"
]
[ addPaymentName loggedData homeModel.add
@@ -56,7 +56,7 @@ view loggedData homeModel =
]
]
-addPaymentName : LoggedData -> AddPaymentModel.Model -> Html
+addPaymentName : LoggedData -> AddPaymentModel.Model -> Html Msg
addPaymentName loggedData addPayment =
div
[ classList
@@ -67,7 +67,7 @@ addPaymentName loggedData addPayment =
[ input
[ id "nameInput"
, value addPayment.name
- , on "input" targetValue (Signal.message Mailbox.address << Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.UpdateAdd << AddPaymentAction.UpdateName)
+ , on "input" (targetValue |> (Json.map <| Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdateAdd << AddPaymentMsg.UpdateName))
, maxlength 20
]
[]
@@ -81,7 +81,7 @@ addPaymentName loggedData addPayment =
text ""
]
-addPaymentCost : LoggedData -> AddPaymentModel.Model -> Html
+addPaymentCost : LoggedData -> AddPaymentModel.Model -> Html Msg
addPaymentCost loggedData addPayment =
div
[ classList
@@ -92,7 +92,7 @@ addPaymentCost loggedData addPayment =
[ input
[ id "costInput"
, value addPayment.cost
- , on "input" targetValue (Signal.message Mailbox.address << Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.UpdateAdd << AddPaymentAction.UpdateCost)
+ , on "input" (targetValue |> (Json.map <| Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdateAdd << AddPaymentMsg.UpdateCost))
, maxlength 7
]
[]
@@ -106,12 +106,12 @@ addPaymentCost loggedData addPayment =
text ""
]
-paymentFrequency : LoggedData -> AddPaymentModel.Model -> Html
+paymentFrequency : LoggedData -> AddPaymentModel.Model -> Html Msg
paymentFrequency loggedData addPayment =
button
[ type' "button"
, class "frequency"
- , onClick Mailbox.address (Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.UpdateAdd <| AddPaymentAction.ToggleFrequency)
+ , onClick (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdateAdd <| AddPaymentMsg.ToggleFrequency)
]
[ div
[ classList