aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm
diff options
context:
space:
mode:
authorJoris2016-04-05 13:39:48 +0200
committerJoris2016-04-05 13:39:48 +0200
commitedca79a7e2bfed1a08de780cc6ab7eac430ef950 (patch)
tree02f794910924f1ca0114d08a254deed98388c70f /src/client/elm
parentd19b69eeeb0c24ee7e4a75b0da32eefba1d43928 (diff)
Add a statistics empty page
Diffstat (limited to 'src/client/elm')
-rw-r--r--src/client/elm/LoggedIn/Action.elm4
-rw-r--r--src/client/elm/LoggedIn/Income/Action.elm (renamed from src/client/elm/LoggedIn/User/Action.elm)2
-rw-r--r--src/client/elm/LoggedIn/Income/Model.elm (renamed from src/client/elm/LoggedIn/User/Model.elm)2
-rw-r--r--src/client/elm/LoggedIn/Income/Update.elm (renamed from src/client/elm/LoggedIn/User/Update.elm)12
-rw-r--r--src/client/elm/LoggedIn/Income/View.elm (renamed from src/client/elm/LoggedIn/User/View.elm)18
-rw-r--r--src/client/elm/LoggedIn/Model.elm6
-rw-r--r--src/client/elm/LoggedIn/Stat/View.elm10
-rw-r--r--src/client/elm/LoggedIn/Update.elm14
-rw-r--r--src/client/elm/LoggedIn/View.elm6
-rw-r--r--src/client/elm/Route.elm9
-rw-r--r--src/client/elm/View/Header.elm53
11 files changed, 77 insertions, 59 deletions
diff --git a/src/client/elm/LoggedIn/Action.elm b/src/client/elm/LoggedIn/Action.elm
index 719e534..b33ab09 100644
--- a/src/client/elm/LoggedIn/Action.elm
+++ b/src/client/elm/LoggedIn/Action.elm
@@ -8,12 +8,12 @@ import Model.Payment exposing (Payment, PaymentId, Frequency)
import Model.Income exposing (IncomeId)
import LoggedIn.Home.Action as HomeAction
-import LoggedIn.User.Action as UserAction
+import LoggedIn.Income.Action as IncomeAction
type Action =
NoOp
| HomeAction HomeAction.Action
- | UserAction UserAction.Action
+ | IncomeAction IncomeAction.Action
| AddPayment String String Frequency
| ValidateAddPayment PaymentId String Int Frequency
diff --git a/src/client/elm/LoggedIn/User/Action.elm b/src/client/elm/LoggedIn/Income/Action.elm
index c5f8d47..68b343a 100644
--- a/src/client/elm/LoggedIn/User/Action.elm
+++ b/src/client/elm/LoggedIn/Income/Action.elm
@@ -1,4 +1,4 @@
-module LoggedIn.User.Action
+module LoggedIn.Income.Action
( Action(..)
) where
diff --git a/src/client/elm/LoggedIn/User/Model.elm b/src/client/elm/LoggedIn/Income/Model.elm
index 4f96a80..fdfb964 100644
--- a/src/client/elm/LoggedIn/User/Model.elm
+++ b/src/client/elm/LoggedIn/Income/Model.elm
@@ -1,4 +1,4 @@
-module LoggedIn.User.Model
+module LoggedIn.Income.Model
( Model
, AddIncome
, init
diff --git a/src/client/elm/LoggedIn/User/Update.elm b/src/client/elm/LoggedIn/Income/Update.elm
index f44fee4..4e673fa 100644
--- a/src/client/elm/LoggedIn/User/Update.elm
+++ b/src/client/elm/LoggedIn/Income/Update.elm
@@ -1,4 +1,4 @@
-module LoggedIn.User.Update
+module LoggedIn.Income.Update
( update
) where
@@ -7,19 +7,19 @@ import Form exposing (Form)
import LoggedData exposing (LoggedData)
-import LoggedIn.User.Model as UserModel
-import LoggedIn.User.Action as UserAction
+import LoggedIn.Income.Model as IncomeModel
+import LoggedIn.Income.Action as IncomeAction
-update : LoggedData -> UserAction.Action -> UserModel.Model -> (UserModel.Model, Effects UserAction.Action)
+update : LoggedData -> IncomeAction.Action -> IncomeModel.Model -> (IncomeModel.Model, Effects IncomeAction.Action)
update loggedData action model =
case action of
- UserAction.NoOp ->
+ IncomeAction.NoOp ->
( model
, Effects.none
)
- UserAction.AddIncomeAction formAction ->
+ IncomeAction.AddIncomeAction formAction ->
( { model | addIncome = Form.update formAction model.addIncome }
, Effects.none
)
diff --git a/src/client/elm/LoggedIn/User/View.elm b/src/client/elm/LoggedIn/Income/View.elm
index 74e2ae2..010b503 100644
--- a/src/client/elm/LoggedIn/User/View.elm
+++ b/src/client/elm/LoggedIn/Income/View.elm
@@ -1,4 +1,4 @@
-module LoggedIn.User.View
+module LoggedIn.Income.View
( view
) where
@@ -15,33 +15,33 @@ import LoggedData exposing (LoggedData)
import Model.Income exposing (IncomeId, Income)
import Model.Translations exposing (getMessage)
-import LoggedIn.User.Model as UserModel
+import LoggedIn.Income.Model as IncomeModel
import Mailbox
import Action
import LoggedIn.Action as LoggedInAction
-import LoggedIn.User.Action as UserAction
+import LoggedIn.Income.Action as IncomeAction
import LoggedIn.View.Date exposing (renderShortDate)
import LoggedIn.View.Price exposing (price)
import Utils.Maybe exposing (isJust)
-view : LoggedData -> UserModel.Model -> Html
-view loggedData userModel =
+view : LoggedData -> IncomeModel.Model -> Html
+view loggedData incomeModel =
div
[]
[ h1 [] [ text <| getMessage "AddIncome" loggedData.translations ]
- , addIncomeView loggedData userModel.addIncome
- , h1 [] [ text <| getMessage "Incomes" loggedData.translations ]
+ , addIncomeView loggedData incomeModel.addIncome
+ , h1 [] [ text <| getMessage "MonthlyNetIncomes" loggedData.translations ]
, incomesView loggedData
]
-addIncomeView : LoggedData -> Form () UserModel.AddIncome -> Html
+addIncomeView : LoggedData -> Form () IncomeModel.AddIncome -> Html
addIncomeView loggedData addIncome =
let
- formAddress = Signal.forwardTo Mailbox.address (Action.UpdateLoggedIn << LoggedInAction.UserAction << UserAction.AddIncomeAction)
+ formAddress = Signal.forwardTo Mailbox.address (Action.UpdateLoggedIn << LoggedInAction.IncomeAction << IncomeAction.AddIncomeAction)
errorFor error field =
if isJust field.liveError
then div [ class "error" ] [ text (getMessage error loggedData.translations) ]
diff --git a/src/client/elm/LoggedIn/Model.elm b/src/client/elm/LoggedIn/Model.elm
index b1639ff..8309528 100644
--- a/src/client/elm/LoggedIn/Model.elm
+++ b/src/client/elm/LoggedIn/Model.elm
@@ -11,11 +11,11 @@ import Model.User exposing (Users, UserId)
import Model.Income exposing (Incomes)
import LoggedIn.Home.Model as HomeModel
-import LoggedIn.User.Model as UserModel
+import LoggedIn.Income.Model as IncomeModel
type alias Model =
{ home : HomeModel.Model
- , user : UserModel.Model
+ , income : IncomeModel.Model
, users : Users
, me : UserId
, payments : Payments
@@ -25,7 +25,7 @@ type alias Model =
init : Init -> Model
init initData =
{ home = HomeModel.init
- , user = UserModel.init
+ , income = IncomeModel.init
, users = initData.users
, me = initData.me
, payments = initData.payments
diff --git a/src/client/elm/LoggedIn/Stat/View.elm b/src/client/elm/LoggedIn/Stat/View.elm
new file mode 100644
index 0000000..e5d1c08
--- /dev/null
+++ b/src/client/elm/LoggedIn/Stat/View.elm
@@ -0,0 +1,10 @@
+module LoggedIn.Stat.View
+ ( view
+ ) where
+
+import Html exposing (..)
+
+import LoggedData exposing (LoggedData)
+
+view : LoggedData -> Html
+view loggedData = text "Stats"
diff --git a/src/client/elm/LoggedIn/Update.elm b/src/client/elm/LoggedIn/Update.elm
index 4598b27..8330310 100644
--- a/src/client/elm/LoggedIn/Update.elm
+++ b/src/client/elm/LoggedIn/Update.elm
@@ -23,8 +23,8 @@ import LoggedIn.Model as LoggedInModel
import LoggedIn.Home.Action as HomeAction
import LoggedIn.Home.Update as HomeUpdate
-import LoggedIn.User.Action as UserAction
-import LoggedIn.User.Update as UserUpdate
+import LoggedIn.Income.Action as IncomeAction
+import LoggedIn.Income.Update as IncomeUpdate
import LoggedIn.Home.AddPayment.Action as AddPaymentAction
import LoggedIn.Home.AddPayment.Update as AddPaymentUpdate
@@ -47,11 +47,11 @@ update model action loggedIn =
, Effects.map LoggedInAction.HomeAction effects
)
- LoggedInAction.UserAction userAction ->
- case UserUpdate.update loggedData userAction loggedIn.user of
- (user, effects) ->
- ( { loggedIn | user = user }
- , Effects.map LoggedInAction.UserAction effects
+ LoggedInAction.IncomeAction incomeAction ->
+ case IncomeUpdate.update loggedData incomeAction loggedIn.income of
+ (income, effects) ->
+ ( { loggedIn | income = income }
+ , Effects.map LoggedInAction.IncomeAction effects
)
LoggedInAction.AddPayment name cost frequency ->
diff --git a/src/client/elm/LoggedIn/View.elm b/src/client/elm/LoggedIn/View.elm
index f9620cc..b1ec4d3 100644
--- a/src/client/elm/LoggedIn/View.elm
+++ b/src/client/elm/LoggedIn/View.elm
@@ -14,7 +14,8 @@ import LoggedData
import LoggedIn.Model as LoggedInModel
import LoggedIn.Home.View as HomeView
-import LoggedIn.User.View as UserView
+import LoggedIn.Income.View as UserView
+import LoggedIn.Stat.View as StatView
view : Model -> LoggedInModel.Model -> Html
view model loggedIn =
@@ -22,4 +23,5 @@ view model loggedIn =
in case TransitRouter.getRoute model of
Empty -> text ""
Home -> HomeView.view loggedData loggedIn.home
- User -> UserView.view loggedData loggedIn.user
+ Income -> UserView.view loggedData loggedIn.income
+ Stat -> StatView.view loggedData
diff --git a/src/client/elm/Route.elm b/src/client/elm/Route.elm
index 8f8518f..0ed4203 100644
--- a/src/client/elm/Route.elm
+++ b/src/client/elm/Route.elm
@@ -11,13 +11,15 @@ import RouteParser exposing (..)
type Route =
Empty
| Home
- | User
+ | Income
+ | Stat
matchers : List (Matcher Route)
matchers =
[ static Empty ""
, static Home "/"
- , static User "/user"
+ , static Income "/income"
+ , static Stat "/statistics"
]
toPath : Route -> String
@@ -25,4 +27,5 @@ toPath route =
case route of
Empty -> ""
Home -> "/"
- User -> "/user"
+ Income -> "/income"
+ Stat -> "/statistics"
diff --git a/src/client/elm/View/Header.elm b/src/client/elm/View/Header.elm
index fb0e880..7a6fefc 100644
--- a/src/client/elm/View/Header.elm
+++ b/src/client/elm/View/Header.elm
@@ -21,28 +21,31 @@ import View.Click exposing (clickTo)
renderHeader : Address Action -> Model -> Html
renderHeader address model =
- header
- []
- [ a
- ( [ class "title" ] ++ clickTo Home)
- [ text (getMessage "SharedCost" model.translations) ]
- , case model.view of
- LoggedInView { me, users } ->
- div
- [ class "signedPanel" ]
- [ a
- ( [ class "user" ] ++ clickTo User)
- [ Dict.get me users
- |> Maybe.map .name
- |> Maybe.withDefault ""
- |> text
- ]
- , button
- [ class "icon"
- , onClick address SignOut
- ]
- [ renderIcon "power-off" ]
- ]
- _ ->
- text ""
- ]
+ let item route name additionalClasses =
+ a
+ ([ class ("item " ++ additionalClasses) ] ++ clickTo route)
+ [ text (getMessage name model.translations) ]
+ in
+ header
+ []
+ ( [item Home "SharedCost" "title"] ++
+ case model.view of
+ LoggedInView { me, users } ->
+ [ item Income "Income" ""
+ , item Stat "Statistics" ""
+ , button
+ [ class "signOut item"
+ , onClick address SignOut
+ ]
+ [ renderIcon "power-off" ]
+ , div
+ [ class "name" ]
+ [ Dict.get me users
+ |> Maybe.map .name
+ |> Maybe.withDefault ""
+ |> text
+ ]
+ ]
+ _ ->
+ []
+ )