aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/View
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/View')
-rw-r--r--src/client/elm/View/LoggedIn/AddPayment.elm29
-rw-r--r--src/client/elm/View/SignIn.elm7
2 files changed, 25 insertions, 11 deletions
diff --git a/src/client/elm/View/LoggedIn/AddPayment.elm b/src/client/elm/View/LoggedIn/AddPayment.elm
index 5739a95..283d392 100644
--- a/src/client/elm/View/LoggedIn/AddPayment.elm
+++ b/src/client/elm/View/LoggedIn/AddPayment.elm
@@ -14,7 +14,7 @@ import Model exposing (Model)
import Model.Payment exposing (PaymentFrequency(..))
import Model.Translations exposing (getMessage)
import Model.Action exposing (..)
-import Model.Action.LoggedInAction exposing (..)
+import Model.Action.LoggedInAction as LoggedInAction exposing (..)
import Model.Action.AddPaymentAction exposing (..)
import Model.Communication as Communication
@@ -22,7 +22,7 @@ import Model.View.LoggedIn.AddPayment exposing (..)
import Model.View.LoggedInView exposing (LoggedInView)
import View.Events exposing (onSubmitPrevDefault)
-import View.Icon exposing (renderIcon)
+import View.Icon exposing (..)
import Utils.Maybe exposing (isJust)
import Utils.Either exposing (toMaybeError)
@@ -30,11 +30,16 @@ import Utils.Either exposing (toMaybeError)
addPayment : Address Action -> Model -> LoggedInView -> Html
addPayment address model loggedInView =
H.form
- [ case (validateName loggedInView.add.name model.translations, validateCost loggedInView.add.cost model.translations) of
- (Ok name, Ok cost) ->
- onSubmitPrevDefault address (ServerCommunication (Communication.AddPayment name cost loggedInView.add.frequency))
- (resName, resCost) ->
- onSubmitPrevDefault address (UpdateLoggedIn <| UpdateAdd <| AddError (toMaybeError resName) (toMaybeError resCost))
+ [ let update =
+ if loggedInView.add.waitingServer
+ then NoOp
+ else
+ case (validateName loggedInView.add.name model.translations, validateCost loggedInView.add.cost model.translations) of
+ (Ok name, Ok cost) ->
+ UpdateLoggedIn <| LoggedInAction.AddPayment name cost loggedInView.add.frequency
+ (resName, resCost) ->
+ UpdateLoggedIn <| UpdateAdd <| AddError (toMaybeError resName) (toMaybeError resCost)
+ in onSubmitPrevDefault address update
, class "addPayment"
]
[ addPaymentName address loggedInView.add
@@ -42,8 +47,14 @@ addPayment address model loggedInView =
, paymentFrequency address model loggedInView.add
, button
[ type' "submit"
- , class "add" ]
- [ text (getMessage "Add" model.translations)]
+ , classList
+ [ ("add", True)
+ , ("waitingServer", loggedInView.add.waitingServer)
+ ]
+ ]
+ [ text (getMessage "Add" model.translations)
+ , if loggedInView.add.waitingServer then renderSpinIcon else text ""
+ ]
]
addPaymentName : Address Action -> AddPayment -> Html
diff --git a/src/client/elm/View/SignIn.elm b/src/client/elm/View/SignIn.elm
index ba16561..4b9f2bb 100644
--- a/src/client/elm/View/SignIn.elm
+++ b/src/client/elm/View/SignIn.elm
@@ -25,9 +25,12 @@ renderSignIn address model signInView =
div
[ class "signIn" ]
[ button
- [ onClick operations.address Persona.SignIn ]
+ ( if signInView.waitingServer
+ then []
+ else [ onClick operations.address Persona.SignIn ]
+ )
[ span [] [ text (getMessage "SignIn" model.translations) ]
- , if signInView.connecting
+ , if signInView.waitingServer
then renderSpinIcon
else renderIcon "power-off"
]