aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/AddPayment
diff options
context:
space:
mode:
authorJoris2016-03-28 17:51:14 +0200
committerJoris2016-03-28 17:51:14 +0200
commit166cd04e4b28770ede854dafc9ae30eae64102fe (patch)
tree2245a31243a165acc6f7355534da44cfd17e6038 /src/client/elm/LoggedIn/AddPayment
parentb0d80a5458d7ba4546e5f01f5b6398ea6d23f981 (diff)
downloadbudget-166cd04e4b28770ede854dafc9ae30eae64102fe.tar.gz
budget-166cd04e4b28770ede854dafc9ae30eae64102fe.tar.bz2
budget-166cd04e4b28770ede854dafc9ae30eae64102fe.zip
Create an empty but reachable user page
Diffstat (limited to 'src/client/elm/LoggedIn/AddPayment')
-rw-r--r--src/client/elm/LoggedIn/AddPayment/Action.elm11
-rw-r--r--src/client/elm/LoggedIn/AddPayment/Model.elm29
-rw-r--r--src/client/elm/LoggedIn/AddPayment/Update.elm55
-rw-r--r--src/client/elm/LoggedIn/AddPayment/View.elm127
4 files changed, 0 insertions, 222 deletions
diff --git a/src/client/elm/LoggedIn/AddPayment/Action.elm b/src/client/elm/LoggedIn/AddPayment/Action.elm
deleted file mode 100644
index 41d4f5b..0000000
--- a/src/client/elm/LoggedIn/AddPayment/Action.elm
+++ /dev/null
@@ -1,11 +0,0 @@
-module LoggedIn.AddPayment.Action
- ( Action(..)
- ) where
-
-type Action =
- NoOp
- | UpdateName String
- | UpdateCost String
- | AddError (Maybe String) (Maybe String)
- | ToggleFrequency
- | WaitingServer
diff --git a/src/client/elm/LoggedIn/AddPayment/Model.elm b/src/client/elm/LoggedIn/AddPayment/Model.elm
deleted file mode 100644
index 2aa32c2..0000000
--- a/src/client/elm/LoggedIn/AddPayment/Model.elm
+++ /dev/null
@@ -1,29 +0,0 @@
-module LoggedIn.AddPayment.Model
- ( Model
- , init
- ) where
-
-import Result as Result exposing (Result(..))
-import Json.Decode exposing ((:=))
-
-import Model.Translations exposing (..)
-import Model.Payment exposing (PaymentFrequency(..))
-
-type alias Model =
- { name : String
- , nameError : Maybe String
- , cost : String
- , costError : Maybe String
- , frequency : PaymentFrequency
- , waitingServer : Bool
- }
-
-init : PaymentFrequency -> Model
-init frequency =
- { name = ""
- , nameError = Nothing
- , cost = ""
- , costError = Nothing
- , frequency = frequency
- , waitingServer = False
- }
diff --git a/src/client/elm/LoggedIn/AddPayment/Update.elm b/src/client/elm/LoggedIn/AddPayment/Update.elm
deleted file mode 100644
index eb4384b..0000000
--- a/src/client/elm/LoggedIn/AddPayment/Update.elm
+++ /dev/null
@@ -1,55 +0,0 @@
-module LoggedIn.AddPayment.Update
- ( update
- , addPaymentError
- ) where
-
-import Maybe
-import Json.Decode as Json exposing ((:=))
-
-import LoggedIn.AddPayment.Action as AddPaymentAction
-import LoggedIn.AddPayment.Model as AddPaymentModel
-
-import Model.Translations exposing (Translations, getMessage)
-import Model.Payment exposing (PaymentFrequency(..))
-
-update : AddPaymentAction.Action -> AddPaymentModel.Model -> AddPaymentModel.Model
-update action addPayment =
- case action of
-
- AddPaymentAction.NoOp ->
- addPayment
-
- AddPaymentAction.UpdateName name ->
- { addPayment | name = name }
-
- AddPaymentAction.UpdateCost cost ->
- { addPayment | cost = cost }
-
- AddPaymentAction.AddError nameError costError ->
- { addPayment
- | nameError = nameError
- , costError = costError
- , waitingServer = False
- }
-
- AddPaymentAction.ToggleFrequency ->
- { addPayment
- | frequency = if addPayment.frequency == Punctual then Monthly else Punctual
- }
-
- AddPaymentAction.WaitingServer ->
- { addPayment | waitingServer = True }
-
-addPaymentError : Translations -> String -> Maybe AddPaymentAction.Action
-addPaymentError translations jsonErr =
- let decoder =
- Json.object2 (,)
- (Json.maybe <| "name" := Json.string)
- (Json.maybe <| "cost" := Json.string)
- in case Json.decodeString decoder jsonErr of
- Err _ ->
- Nothing
- Ok (mbNameKey, mbCostKey) ->
- Just <| AddPaymentAction.AddError
- (Maybe.map (flip getMessage translations) mbNameKey)
- (Maybe.map (flip getMessage translations) mbCostKey)
diff --git a/src/client/elm/LoggedIn/AddPayment/View.elm b/src/client/elm/LoggedIn/AddPayment/View.elm
deleted file mode 100644
index 90f4f02..0000000
--- a/src/client/elm/LoggedIn/AddPayment/View.elm
+++ /dev/null
@@ -1,127 +0,0 @@
-module LoggedIn.AddPayment.View
- ( view
- ) 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 LoggedIn.AddPayment.Action as AddPaymentAction
-import LoggedIn.AddPayment.Model as AddPaymentModel
-
-import Model exposing (Model)
-import Model.Payment exposing (PaymentFrequency(..))
-import Model.Translations exposing (getMessage)
-import Action as Action exposing (..)
-
-import View.Events exposing (onSubmitPrevDefault)
-import View.Icon exposing (..)
-
-import Utils.Maybe exposing (isJust)
-import Utils.Either exposing (toMaybeError)
-
-view : Address Action -> Model -> LoggedInModel.Model -> Html
-view 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 -> AddPaymentModel.Model -> 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 << AddPaymentAction.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 -> AddPaymentModel.Model -> 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 << AddPaymentAction.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 -> AddPaymentModel.Model -> Html
-paymentFrequency address model addPayment =
- button
- [ type' "button"
- , class "frequency"
- , onClick address (UpdateLoggedIn << LoggedInAction.UpdateAdd <| AddPaymentAction.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) ]
- ]