diff options
author | Joris | 2016-04-05 23:52:13 +0200 |
---|---|---|
committer | Joris | 2016-04-05 23:52:13 +0200 |
commit | fe50c4042848681833d15fab27466d1d2d4bda45 (patch) | |
tree | 9a1eda4adb22c0d84815e20e8e021968815d7c50 /src/client | |
parent | 466f77394885cb74d01451c4733cafc9b61f4bba (diff) |
Ameliore design in income page and stat page
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/elm/LoggedIn/Home/Account/View.elm | 4 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/View.elm | 2 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/View/Monthly.elm | 6 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/View/Table.elm | 4 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Income/View.elm | 8 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Stat/View.elm | 45 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/View.elm | 16 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/View/Format.elm (renamed from src/client/elm/LoggedIn/View/Price.elm) | 8 | ||||
-rw-r--r-- | src/client/elm/View/Plural.elm | 7 |
9 files changed, 65 insertions, 35 deletions
diff --git a/src/client/elm/LoggedIn/Home/Account/View.elm b/src/client/elm/LoggedIn/Home/Account/View.elm index 63fb997..bec75d5 100644 --- a/src/client/elm/LoggedIn/Home/Account/View.elm +++ b/src/client/elm/LoggedIn/Home/Account/View.elm @@ -9,7 +9,7 @@ import LoggedData exposing (LoggedData) import LoggedIn.Home.Model as HomeModel import LoggedIn.Home.Model.Payer exposing (..) -import LoggedIn.View.Price exposing (price) +import LoggedIn.View.Format as Format import Model exposing (Model) import Model.User exposing (getUserName) @@ -36,5 +36,5 @@ exceedingPayer loggedData homeModel payer = ] , span [ class "amount" ] - [ text ("+ " ++ (price loggedData.conf payer.amount)) ] + [ text ("+ " ++ (Format.price loggedData.conf payer.amount)) ] ] diff --git a/src/client/elm/LoggedIn/Home/View.elm b/src/client/elm/LoggedIn/Home/View.elm index 7e6ba40..43cc9cf 100644 --- a/src/client/elm/LoggedIn/Home/View.elm +++ b/src/client/elm/LoggedIn/Home/View.elm @@ -20,7 +20,7 @@ import Mailbox view : LoggedData -> LoggedInModel.Model -> Html view loggedData loggedIn = div - [ class "loggedIn" ] + [ class "home" ] [ AddPaymentView.view loggedData loggedIn , div [ class "expandables" ] diff --git a/src/client/elm/LoggedIn/Home/View/Monthly.elm b/src/client/elm/LoggedIn/Home/View/Monthly.elm index c001331..237b551 100644 --- a/src/client/elm/LoggedIn/Home/View/Monthly.elm +++ b/src/client/elm/LoggedIn/Home/View/Monthly.elm @@ -12,7 +12,7 @@ import LoggedIn.Action as LoggedInAction import LoggedIn.Home.Action as HomeAction import LoggedIn.Home.Model as HomeModel -import LoggedIn.View.Price exposing (price) +import LoggedIn.View.Format as Format import LoggedIn.Home.View.Expand exposing (..) import Model.Payment as Payment exposing (Payments, Payment, monthly) @@ -52,7 +52,7 @@ monthlyCount loggedData monthlyPayments homeModel = [ class "header" , onClick Mailbox.address (Action.UpdateLoggedIn << LoggedInAction.HomeAction <| HomeAction.ToggleMonthlyDetail) ] - [ text (getParamMessage [toString count, price loggedData.conf total] key loggedData.translations) + [ text (getParamMessage [toString count, Format.price loggedData.conf total] key loggedData.translations) , expand ExpandDown homeModel.monthlyDetail ] @@ -81,7 +81,7 @@ paymentLine loggedData homeModel payment = , ("refund", payment.cost < 0) ] ] - [ text (price loggedData.conf payment.cost) ] + [ text (Format.price loggedData.conf payment.cost) ] , div [ class "cell delete" , onClick Mailbox.address (Action.UpdateLoggedIn <| LoggedInAction.DeletePayment payment.id) diff --git a/src/client/elm/LoggedIn/Home/View/Table.elm b/src/client/elm/LoggedIn/Home/View/Table.elm index 71aa4e5..5ac740c 100644 --- a/src/client/elm/LoggedIn/Home/View/Table.elm +++ b/src/client/elm/LoggedIn/Home/View/Table.elm @@ -17,7 +17,7 @@ import LoggedIn.Action as LoggedInAction import LoggedIn.Home.Action as HomeAction import LoggedIn.Home.Model as HomeModel import LoggedIn.View.Date exposing (..) -import LoggedIn.View.Price exposing (price) +import LoggedIn.View.Format as Format import Model.User exposing (getUserName) import Model.Payment as Payment exposing (..) @@ -68,7 +68,7 @@ paymentLine loggedData homeModel payment = , ("refund", payment.cost < 0) ] ] - [ text (price loggedData.conf payment.cost) ] + [ text (Format.price loggedData.conf payment.cost) ] , div [ class "cell user" ] [ payment.userId diff --git a/src/client/elm/LoggedIn/Income/View.elm b/src/client/elm/LoggedIn/Income/View.elm index 010b503..f62902a 100644 --- a/src/client/elm/LoggedIn/Income/View.elm +++ b/src/client/elm/LoggedIn/Income/View.elm @@ -24,14 +24,14 @@ import LoggedIn.Action as LoggedInAction import LoggedIn.Income.Action as IncomeAction import LoggedIn.View.Date exposing (renderShortDate) -import LoggedIn.View.Price exposing (price) +import LoggedIn.View.Format as Format import Utils.Maybe exposing (isJust) view : LoggedData -> IncomeModel.Model -> Html view loggedData incomeModel = div - [] + [ class "income" ] [ h1 [] [ text <| getMessage "AddIncome" loggedData.translations ] , addIncomeView loggedData incomeModel.addIncome , h1 [] [ text <| getMessage "MonthlyNetIncomes" loggedData.translations ] @@ -71,7 +71,7 @@ addIncomeView loggedData addIncome = incomesView : LoggedData -> Html incomesView loggedData = - ol + ul [] ( loggedData.incomes |> Dict.toList @@ -87,7 +87,7 @@ incomeView loggedData (incomeId, income) = [] [ text <| renderShortDate (Date.fromTime income.creation) loggedData.translations , text " − " - , text <| price loggedData.conf income.amount + , text <| Format.price loggedData.conf income.amount , text " − " , button [ onClick Mailbox.address (Action.UpdateLoggedIn <| LoggedInAction.DeleteIncome incomeId) ] diff --git a/src/client/elm/LoggedIn/Stat/View.elm b/src/client/elm/LoggedIn/Stat/View.elm index 76acd8f..3fe9d1f 100644 --- a/src/client/elm/LoggedIn/Stat/View.elm +++ b/src/client/elm/LoggedIn/Stat/View.elm @@ -3,40 +3,59 @@ module LoggedIn.Stat.View ) where import Html exposing (..) +import Html.Attributes exposing (..) import LoggedData exposing (LoggedData) -import Model.Payment exposing (Payments) +import Model.Payment as Payment exposing (Payments) import Model.Conf exposing (Conf) +import Model.Translations exposing (getMessage) -import LoggedIn.View.Price exposing (price) +import LoggedIn.View.Format as Format + +import View.Plural exposing (plural) view : LoggedData -> Html view loggedData = div - [] - [ h1 [] [ text "Total" ] - , paymentDetail loggedData.conf loggedData.payments + [ class "stat" ] + [ h1 [] [ text (getMessage "Overall" loggedData.translations) ] + , paymentsDetail loggedData (Payment.punctual loggedData.payments) + , h1 [] [ text (getMessage "ByMonths" loggedData.translations) ] + , monthsDetail loggedData ] -paymentDetail : Conf -> Payments -> Html -paymentDetail conf payments = +paymentsDetail : LoggedData -> Payments -> Html +paymentsDetail loggedData payments = ul [] [ li [] - [ payments - |> List.length - |> toString - |> text - , text " payments" + [ let single = getMessage "Payment" loggedData.translations + multiple = getMessage "Payments" loggedData.translations + in text <| plural (List.length payments) single multiple ] , li [] [ payments |> List.map .cost |> List.sum - |> price conf + |> Format.price loggedData.conf |> text ] ] + +monthsDetail : LoggedData -> Html +monthsDetail loggedData = + ul + [] + [] + +monthDetail : String -> Int -> Html +monthDetail month amount = + li + [] + [ text month + , text " " + , text (toString amount) + ] diff --git a/src/client/elm/LoggedIn/View.elm b/src/client/elm/LoggedIn/View.elm index b1ec4d3..dbbab33 100644 --- a/src/client/elm/LoggedIn/View.elm +++ b/src/client/elm/LoggedIn/View.elm @@ -3,6 +3,7 @@ module LoggedIn.View ) where import Html exposing (..) +import Html.Attributes exposing (..) import TransitRouter import Route exposing (..) @@ -19,9 +20,12 @@ import LoggedIn.Stat.View as StatView view : Model -> LoggedInModel.Model -> Html view model loggedIn = - let loggedData = LoggedData.build model loggedIn - in case TransitRouter.getRoute model of - Empty -> text "" - Home -> HomeView.view loggedData loggedIn.home - Income -> UserView.view loggedData loggedIn.income - Stat -> StatView.view loggedData + div + [ class "loggedIn" ] + [ let loggedData = LoggedData.build model loggedIn + in case TransitRouter.getRoute model of + Empty -> text "" + Home -> HomeView.view loggedData loggedIn.home + Income -> UserView.view loggedData loggedIn.income + Stat -> StatView.view loggedData + ] diff --git a/src/client/elm/LoggedIn/View/Price.elm b/src/client/elm/LoggedIn/View/Format.elm index 2bfed23..7925a5c 100644 --- a/src/client/elm/LoggedIn/View/Price.elm +++ b/src/client/elm/LoggedIn/View/Format.elm @@ -1,4 +1,4 @@ -module LoggedIn.View.Price +module LoggedIn.View.Format ( price ) where @@ -8,13 +8,13 @@ import Model.Conf exposing (Conf) price : Conf -> Int -> String price conf amount = - ( formatInt amount + ( number amount ++ " " ++ conf.currency ) -formatInt : Int -> String -formatInt n = +number : Int -> String +number n = abs n |> toString |> toList diff --git a/src/client/elm/View/Plural.elm b/src/client/elm/View/Plural.elm new file mode 100644 index 0000000..6e480fd --- /dev/null +++ b/src/client/elm/View/Plural.elm @@ -0,0 +1,7 @@ +module View.Plural + ( plural + ) where + +plural : Int -> String -> String -> String +plural n single multiple = + (toString n) ++ " " ++ if n <= 1 then single else multiple |