From 8e3a7bf1cb83bbb6e3dcd54308eefa52a29cd679 Mon Sep 17 00:00:00 2001 From: Joris Date: Fri, 3 Jun 2016 20:27:16 +0200 Subject: Migrate to elm 0.17 --- src/client/elm/LoggedIn/Home/AddPayment/Action.elm | 14 --------- src/client/elm/LoggedIn/Home/AddPayment/Model.elm | 4 +-- src/client/elm/LoggedIn/Home/AddPayment/Msg.elm | 14 +++++++++ src/client/elm/LoggedIn/Home/AddPayment/Update.elm | 26 ++++++++-------- src/client/elm/LoggedIn/Home/AddPayment/View.elm | 36 +++++++++++----------- 5 files changed, 47 insertions(+), 47 deletions(-) delete mode 100644 src/client/elm/LoggedIn/Home/AddPayment/Action.elm create mode 100644 src/client/elm/LoggedIn/Home/AddPayment/Msg.elm (limited to 'src/client/elm/LoggedIn/Home/AddPayment') diff --git a/src/client/elm/LoggedIn/Home/AddPayment/Action.elm b/src/client/elm/LoggedIn/Home/AddPayment/Action.elm deleted file mode 100644 index a692b15..0000000 --- a/src/client/elm/LoggedIn/Home/AddPayment/Action.elm +++ /dev/null @@ -1,14 +0,0 @@ -module LoggedIn.Home.AddPayment.Action - ( Action(..) - ) where - -import Model.Payment exposing (Frequency) - -type Action = - NoOp - | Init Frequency - | UpdateName String - | UpdateCost String - | AddError (Maybe String) (Maybe String) - | ToggleFrequency - | WaitingServer 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/Msg.elm b/src/client/elm/LoggedIn/Home/AddPayment/Msg.elm new file mode 100644 index 0000000..53e6e26 --- /dev/null +++ b/src/client/elm/LoggedIn/Home/AddPayment/Msg.elm @@ -0,0 +1,14 @@ +module LoggedIn.Home.AddPayment.Msg exposing + ( Msg(..) + ) + +import Model.Payment exposing (Frequency) + +type Msg = + NoOp + | Init Frequency + | UpdateName String + | UpdateCost String + | AddError (Maybe String) (Maybe String) + | ToggleFrequency + | WaitingServer 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 -- cgit v1.2.3