From 1c7d6ea6e3bcd3c672cb5eb3cf22ffc88cabb257 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 20 Mar 2016 22:38:44 +0100 Subject: use config-manager instead of ConfigFile --- src/client/elm/Main.elm | 4 ++-- src/client/elm/Model.elm | 12 ++++++------ src/client/elm/Model/Conf.elm | 13 +++++++++++++ src/client/elm/Model/Config.elm | 18 ------------------ src/client/elm/View/LoggedIn/AddPayment.elm | 2 +- src/client/elm/View/LoggedIn/Table.elm | 2 +- src/client/elm/View/Price.elm | 2 +- 7 files changed, 24 insertions(+), 29 deletions(-) create mode 100644 src/client/elm/Model/Conf.elm delete mode 100644 src/client/elm/Model/Config.elm (limited to 'src/client/elm') diff --git a/src/client/elm/Main.elm b/src/client/elm/Main.elm index b4b440b..06b5ec3 100644 --- a/src/client/elm/Main.elm +++ b/src/client/elm/Main.elm @@ -26,7 +26,7 @@ main = app.html app : App Model app = StartApp.start { init = - ( initialModel initialTime translations config + ( initialModel initialTime translations conf , Server.init |> Task.map GoLoggedInView |> flip Task.onError (always <| Task.succeed GoSignInView) @@ -44,7 +44,7 @@ port tasks = app.tasks port initialTime : Time port translations : String -port config : String +port conf : String -- Output ports diff --git a/src/client/elm/Model.elm b/src/client/elm/Model.elm index 43a19c5..5dc6692 100644 --- a/src/client/elm/Model.elm +++ b/src/client/elm/Model.elm @@ -8,25 +8,25 @@ import Json.Decode as Json import Model.View exposing (..) import Model.Translations exposing (..) -import Model.Config exposing (..) +import Model.Conf exposing (..) type alias Model = { view : View , currentTime : Time , translations : Translations - , config : Config + , conf : Conf } initialModel : Time -> String -> String -> Model -initialModel initialTime translationsValue configValue = +initialModel initialTime translationsValue confValue = { view = LoadingView , currentTime = initialTime , translations = case Json.decodeString translationsDecoder translationsValue of Ok translations -> translations Err err -> [] - , config = - case Json.decodeString configDecoder configValue of - Ok config -> config + , conf = + case Json.decodeString confDecoder confValue of + Ok conf -> conf Err err -> { currency = "" } } diff --git a/src/client/elm/Model/Conf.elm b/src/client/elm/Model/Conf.elm new file mode 100644 index 0000000..ad71d83 --- /dev/null +++ b/src/client/elm/Model/Conf.elm @@ -0,0 +1,13 @@ +module Model.Conf + ( Conf + , confDecoder + ) where + +import Json.Decode exposing (..) + +type alias Conf = + { currency : String + } + +confDecoder : Decoder Conf +confDecoder = object1 Conf ("currency" := string) diff --git a/src/client/elm/Model/Config.elm b/src/client/elm/Model/Config.elm deleted file mode 100644 index e47b032..0000000 --- a/src/client/elm/Model/Config.elm +++ /dev/null @@ -1,18 +0,0 @@ -module Model.Config - ( Config - , configDecoder - ) where - -import Json.Decode exposing (..) - -type alias Config = - { currency : String - } - -configDecoder : Decoder Config -configDecoder = object1 Config ("currency" := string) - -defaultConfig : Config -defaultConfig = - { currency = "€" - } diff --git a/src/client/elm/View/LoggedIn/AddPayment.elm b/src/client/elm/View/LoggedIn/AddPayment.elm index 0149432..7c0d34b 100644 --- a/src/client/elm/View/LoggedIn/AddPayment.elm +++ b/src/client/elm/View/LoggedIn/AddPayment.elm @@ -94,7 +94,7 @@ addPaymentCost address model addPayment = [] , label [ for "costInput" ] - [ text model.config.currency ] + [ text model.conf.currency ] , case addPayment.costError of Just error -> div [ class "errorMessage" ] [ text error ] diff --git a/src/client/elm/View/LoggedIn/Table.elm b/src/client/elm/View/LoggedIn/Table.elm index ca5680f..4c302a5 100644 --- a/src/client/elm/View/LoggedIn/Table.elm +++ b/src/client/elm/View/LoggedIn/Table.elm @@ -34,7 +34,7 @@ headerLine model = div [ class "header" ] [ div [ class "cell category" ] [ renderIcon "shopping-cart" ] - , div [ class "cell cost" ] [ text model.config.currency ] + , div [ class "cell cost" ] [ text model.conf.currency ] , div [ class "cell user" ] [ renderIcon "user" ] , div [ class "cell date" ] [ renderIcon "calendar" ] , div [ class "cell" ] [] diff --git a/src/client/elm/View/Price.elm b/src/client/elm/View/Price.elm index 286bcaa..be665a8 100644 --- a/src/client/elm/View/Price.elm +++ b/src/client/elm/View/Price.elm @@ -11,7 +11,7 @@ price : Model -> Int -> String price model amount = ( formatInt amount ++ " " - ++ model.config.currency + ++ model.conf.currency ) formatInt : Int -> String -- cgit v1.2.3