From 0d589e12a0c32936303de46b1e462dd19648170d Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Sun, 19 Jul 2015 16:07:15 +0200 Subject: Login with a token validation --- src/client/View/Page.elm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/client/View') diff --git a/src/client/View/Page.elm b/src/client/View/Page.elm index 1683cf3..eb86132 100644 --- a/src/client/View/Page.elm +++ b/src/client/View/Page.elm @@ -13,11 +13,14 @@ import Date exposing (Date) import String exposing (append) +import Json.Decode as Json + import Model exposing (Model) import Model.Payment exposing (Payments, Payment) import Model.View exposing (..) import Update exposing (..) +import Update.SignIn exposing (..) import ServerCommunication as SC import ServerCommunication exposing (serverCommunications) @@ -38,7 +41,7 @@ renderHeader model = [] [ h1 [] - [ text "Payments" ] + [ text "Shared Cost" ] , case model.view of LoadingView -> text "" @@ -57,7 +60,7 @@ renderMain model = case model.view of LoadingView -> loadingView - SignInView login -> + SignInView { login } -> signInView login PaymentView payments -> paymentsView payments @@ -67,18 +70,25 @@ loadingView = text "" signInView : String -> Html signInView login = - H.form + div [ class "signIn" ] [ input [ value login - , on "input" targetValue (Signal.message actions.address << UpdateLogin) + , on "input" targetValue (Signal.message actions.address << UpdateSignIn << UpdateLogin) + , onEnter serverCommunications.address (SC.SignIn login) ] [] , button [ onClick serverCommunications.address (SC.SignIn login) ] - [ renderIcon "sign-in" ] + [ text "Sign in" ] ] +onEnter : Signal.Address a -> a -> Attribute +onEnter address value = + on "keydown" + (Json.customDecoder keyCode (\code -> if code == 13 then Ok () else Err "")) + (\_ -> Signal.message address value) + paymentsView : Payments -> Html paymentsView payments = table @@ -112,5 +122,5 @@ paymentLine payment = renderDate : Date -> String renderDate date = toString (Date.day date) - |> flip append (" " ++ (toString (Date.month date))) + |> flip append (" " ++ (toString (Date.month date)) ++ ".") |> flip append (" " ++ (toString (Date.year date))) -- cgit v1.2.3