aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2015-11-01 10:49:08 +0100
committerJoris2015-11-01 10:49:08 +0100
commita14af8d8f2cc9d561a8c8804a4c73b9a35ce8a97 (patch)
treef260b8a663449d30bae32b0f1cfd70bad323d8c6
parentb886ef9b847b63528a40c41b333937007b8f57c5 (diff)
Set currency in conf instead of in messages
-rw-r--r--config.txt2
-rw-r--r--src/client/Model.elm3
-rw-r--r--src/client/Model/Conf.elm7
-rw-r--r--src/client/View/LoggedIn/Add.elm2
-rw-r--r--src/client/View/LoggedIn/Table.elm2
-rw-r--r--src/client/View/Price.elm2
-rw-r--r--src/server/Config.hs4
-rw-r--r--src/server/Model/Message/Key.hs1
-rw-r--r--src/server/Model/Message/Translations.hs5
9 files changed, 16 insertions, 12 deletions
diff --git a/config.txt b/config.txt
index 1c9e0b0..f6d33b0 100644
--- a/config.txt
+++ b/config.txt
@@ -1,4 +1,4 @@
hostname = localhost:3001
port = 3001
sign-in-expiration-mn = 5
-currency = €
+currency = $
diff --git a/src/client/Model.elm b/src/client/Model.elm
index 72db56a..c330d86 100644
--- a/src/client/Model.elm
+++ b/src/client/Model.elm
@@ -8,11 +8,13 @@ import Json.Decode as Json
import Model.View exposing (..)
import Model.Translations exposing (..)
+import Model.Conf exposing (..)
type alias Model =
{ view : View
, currentTime : Time
, translations : Translations
+ , conf : Conf
}
initialModel : Time -> String -> Model
@@ -23,4 +25,5 @@ initialModel initialTime translationsValue =
case Json.decodeString translationsDecoder translationsValue of
Ok translations -> translations
Err err -> []
+ , conf = { currency = "€" }
}
diff --git a/src/client/Model/Conf.elm b/src/client/Model/Conf.elm
new file mode 100644
index 0000000..183fd68
--- /dev/null
+++ b/src/client/Model/Conf.elm
@@ -0,0 +1,7 @@
+module Model.Conf
+ ( Conf
+ ) where
+
+type alias Conf =
+ { currency : String
+ }
diff --git a/src/client/View/LoggedIn/Add.elm b/src/client/View/LoggedIn/Add.elm
index 52d931a..4f75822 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 (getMessage "MoneySymbol" model.translations) ]
+ [ text model.conf.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 9d28e81..2cfc6d6 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 (getMessage "MoneySymbol" model.translations) ]
+ , 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/View/Price.elm b/src/client/View/Price.elm
index cb8abd2..be665a8 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
++ " "
- ++ getMessage "MoneySymbol" model.translations
+ ++ model.conf.currency
)
formatInt : Int -> String
diff --git a/src/server/Config.hs b/src/server/Config.hs
index deb2e68..bd7f325 100644
--- a/src/server/Config.hs
+++ b/src/server/Config.hs
@@ -19,7 +19,7 @@ data Config = Config
{ hostname :: Text
, port :: Int
, signInExpirationMn :: Int
- , currency :: Char
+ , currency :: Text
} deriving (Read, Eq, Show)
getConfig :: FilePath -> IO (Either Text Config)
@@ -30,5 +30,5 @@ getConfig filePath =
(T.pack <$> get cp "DEFAULT" "hostname") <*>
(get cp "DEFAULT" "port") <*>
(get cp "DEFAULT" "sign-in-expiration-mn") <*>
- (get cp "DEFAULT" "currency")
+ (T.pack <$> get cp "DEFAULT" "currency")
)
diff --git a/src/server/Model/Message/Key.hs b/src/server/Model/Message/Key.hs
index c4ff738..e9f8ef6 100644
--- a/src/server/Model/Message/Key.hs
+++ b/src/server/Model/Message/Key.hs
@@ -53,7 +53,6 @@ data Key =
| Add
| PaymentNotDeleted
- | MoneySymbol
| Punctual
| Monthly
| SingularMonthlyCount
diff --git a/src/server/Model/Message/Translations.hs b/src/server/Model/Message/Translations.hs
index f34cbd2..a2e9a30 100644
--- a/src/server/Model/Message/Translations.hs
+++ b/src/server/Model/Message/Translations.hs
@@ -220,11 +220,6 @@ m l PaymentNotDeleted =
English -> "The payment could not have been deleted."
French -> "Le paiement n'a pas pu être supprimé."
-m l MoneySymbol =
- case l of
- English -> "$"
- French -> "€"
-
m l Punctual =
case l of
English -> "Punctual"