From 0c9d2b91e73f045067f7bcce6e4235fc9008f309 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 27 Mar 2016 21:13:37 +0200 Subject: Regroup add payment modules --- src/client/elm/View/LoggedIn/AddPayment.elm | 127 ---------------------------- 1 file changed, 127 deletions(-) delete mode 100644 src/client/elm/View/LoggedIn/AddPayment.elm (limited to 'src/client/elm/View/LoggedIn/AddPayment.elm') diff --git a/src/client/elm/View/LoggedIn/AddPayment.elm b/src/client/elm/View/LoggedIn/AddPayment.elm deleted file mode 100644 index 010ecd3..0000000 --- a/src/client/elm/View/LoggedIn/AddPayment.elm +++ /dev/null @@ -1,127 +0,0 @@ -module View.LoggedIn.AddPayment - ( addPayment - ) where - -import Result exposing (..) -import Signal exposing (Address) - -import Html as H exposing (..) -import Html.Attributes exposing (..) -import Html.Events exposing (..) - -import LoggedIn.Action as LoggedInAction -import LoggedIn.Model as LoggedInModel - -import Model exposing (Model) -import Model.Payment exposing (PaymentFrequency(..)) -import Model.Translations exposing (getMessage) -import Model.Action as Action exposing (..) -import Model.Action.AddPaymentAction exposing (..) - -import Model.View.LoggedIn.AddPayment exposing (..) - -import View.Events exposing (onSubmitPrevDefault) -import View.Icon exposing (..) - -import Utils.Maybe exposing (isJust) -import Utils.Either exposing (toMaybeError) - -addPayment : Address Action -> Model -> LoggedInModel.Model -> Html -addPayment address model loggedInModel = - H.form - [ let update = - if loggedInModel.add.waitingServer - then - Action.NoOp - else - UpdateLoggedIn <| LoggedInAction.AddPayment loggedInModel.add.name loggedInModel.add.cost loggedInModel.add.frequency - in onSubmitPrevDefault address update - , class "addPayment" - ] - [ addPaymentName address loggedInModel.add - , addPaymentCost address model loggedInModel.add - , paymentFrequency address model loggedInModel.add - , button - [ type' "submit" - , classList - [ ("add", True) - , ("waitingServer", loggedInModel.add.waitingServer) - ] - ] - [ text (getMessage "Add" model.translations) - , if loggedInModel.add.waitingServer then renderSpinIcon else text "" - ] - ] - -addPaymentName : Address Action -> AddPayment -> Html -addPaymentName address addPayment = - div - [ classList - [ ("name", True) - , ("error", isJust addPayment.nameError) - ] - ] - [ input - [ id "nameInput" - , value addPayment.name - , on "input" targetValue (Signal.message address << UpdateLoggedIn << LoggedInAction.UpdateAdd << UpdateName) - , maxlength 20 - ] - [] - , label - [ for "nameInput" ] - [ renderIcon "shopping-cart" ] - , case addPayment.nameError of - Just error -> - div [ class "errorMessage" ] [ text error ] - Nothing -> - text "" - ] - -addPaymentCost : Address Action -> Model -> AddPayment -> Html -addPaymentCost address model addPayment = - div - [ classList - [ ("cost", True) - , ("error", isJust addPayment.costError) - ] - ] - [ input - [ id "costInput" - , value addPayment.cost - , on "input" targetValue (Signal.message address << UpdateLoggedIn << LoggedInAction.UpdateAdd << UpdateCost) - , maxlength 7 - ] - [] - , label - [ for "costInput" ] - [ text model.conf.currency ] - , case addPayment.costError of - Just error -> - div [ class "errorMessage" ] [ text error ] - Nothing -> - text "" - ] - -paymentFrequency : Address Action -> Model -> AddPayment -> Html -paymentFrequency address model addPayment = - button - [ type' "button" - , class "frequency" - , onClick address (UpdateLoggedIn << LoggedInAction.UpdateAdd <| ToggleFrequency) - ] - [ div - [ classList - [ ("punctual", True) - , ("selected", addPayment.frequency == Punctual) - ] - ] - [ text (getMessage "Punctual" model.translations) ] - , div - [ classList - [ ("monthly", True) - , ("selected", addPayment.frequency == Monthly) - ] - ] - [ text (getMessage "Monthly" model.translations) ] - ] -- cgit v1.2.3