diff options
author | Joris | 2015-11-01 11:58:42 +0100 |
---|---|---|
committer | Joris | 2015-11-01 11:58:42 +0100 |
commit | c015db01e2acee9d1fc83cd6a762d0a3e629b353 (patch) | |
tree | 9e6b8f5fa04a3ce6cca51f5cae4cc8fbf6a0f5ed /src/client | |
parent | d3e045e8034c5473964c0529ffc1e181311842c2 (diff) |
Use in client the real currency set in config.txt
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/Main.elm | 7 | ||||
-rw-r--r-- | src/client/Model.elm | 13 | ||||
-rw-r--r-- | src/client/Model/Conf.elm | 7 | ||||
-rw-r--r-- | src/client/Model/Config.elm | 18 | ||||
-rw-r--r-- | src/client/View/LoggedIn/Add.elm | 2 | ||||
-rw-r--r-- | src/client/View/LoggedIn/Table.elm | 2 | ||||
-rw-r--r-- | src/client/View/Price.elm | 2 |
7 files changed, 35 insertions, 16 deletions
diff --git a/src/client/Main.elm b/src/client/Main.elm index de98809..4f96675 100644 --- a/src/client/Main.elm +++ b/src/client/Main.elm @@ -17,6 +17,7 @@ import Model.User exposing (Users, usersDecoder, UserId, userIdDecoder) import Model.Payment exposing (Payments, paymentsDecoder, perPage) import Model.Payer exposing (Payers, payersDecoder) import Model.Translations exposing (..) +import Model.Config exposing (..) import Update exposing (Action(..), actions, updateModel) import Update.SignIn exposing (..) @@ -29,7 +30,7 @@ main : Signal Html main = Signal.map renderPage model model : Signal Model -model = Signal.foldp updateModel (initialModel initialTime translations) update +model = Signal.foldp updateModel (initialModel initialTime translations config) update update : Signal Action update = Signal.mergeMany @@ -51,6 +52,10 @@ port translations : String --------------------------------------- +port config : String + +--------------------------------------- + port initView : Task Http.Error () port initView = case signInError of diff --git a/src/client/Model.elm b/src/client/Model.elm index c330d86..43a19c5 100644 --- a/src/client/Model.elm +++ b/src/client/Model.elm @@ -8,22 +8,25 @@ import Json.Decode as Json import Model.View exposing (..) import Model.Translations exposing (..) -import Model.Conf exposing (..) +import Model.Config exposing (..) type alias Model = { view : View , currentTime : Time , translations : Translations - , conf : Conf + , config : Config } -initialModel : Time -> String -> Model -initialModel initialTime translationsValue = +initialModel : Time -> String -> String -> Model +initialModel initialTime translationsValue configValue = { view = LoadingView , currentTime = initialTime , translations = case Json.decodeString translationsDecoder translationsValue of Ok translations -> translations Err err -> [] - , conf = { currency = "€" } + , config = + case Json.decodeString configDecoder configValue of + Ok config -> config + Err err -> { currency = "" } } diff --git a/src/client/Model/Conf.elm b/src/client/Model/Conf.elm deleted file mode 100644 index 183fd68..0000000 --- a/src/client/Model/Conf.elm +++ /dev/null @@ -1,7 +0,0 @@ -module Model.Conf - ( Conf - ) where - -type alias Conf = - { currency : String - } diff --git a/src/client/Model/Config.elm b/src/client/Model/Config.elm new file mode 100644 index 0000000..e47b032 --- /dev/null +++ b/src/client/Model/Config.elm @@ -0,0 +1,18 @@ +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/View/LoggedIn/Add.elm b/src/client/View/LoggedIn/Add.elm index 4f75822..572bdf6 100644 --- a/src/client/View/LoggedIn/Add.elm +++ b/src/client/View/LoggedIn/Add.elm @@ -90,7 +90,7 @@ addPaymentCost model addPayment = [] , label [ for "costInput" ] - [ text model.conf.currency ] + [ text model.config.currency ] , case addPayment.costError of Just error -> div [ class "errorMessage" ] [ text error ] diff --git a/src/client/View/LoggedIn/Table.elm b/src/client/View/LoggedIn/Table.elm index 2cfc6d6..f5a08b5 100644 --- a/src/client/View/LoggedIn/Table.elm +++ b/src/client/View/LoggedIn/Table.elm @@ -38,7 +38,7 @@ headerLine model = div [ class "header" ] [ div [ class "cell category" ] [ renderIcon "shopping-cart" ] - , div [ class "cell cost" ] [ text model.conf.currency ] + , div [ class "cell cost" ] [ text model.config.currency ] , div [ class "cell user" ] [ renderIcon "user" ] , div [ class "cell date" ] [ renderIcon "calendar" ] , div [ class "cell" ] [] diff --git a/src/client/View/Price.elm b/src/client/View/Price.elm index be665a8..286bcaa 100644 --- a/src/client/View/Price.elm +++ b/src/client/View/Price.elm @@ -11,7 +11,7 @@ price : Model -> Int -> String price model amount = ( formatInt amount ++ " " - ++ model.conf.currency + ++ model.config.currency ) formatInt : Int -> String |