aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm')
-rw-r--r--src/client/elm/LoggedIn/Action.elm21
-rw-r--r--src/client/elm/LoggedIn/Model.elm37
-rw-r--r--src/client/elm/LoggedIn/Update.elm136
-rw-r--r--src/client/elm/LoggedIn/View.elm34
-rw-r--r--src/client/elm/Model/Action.elm4
-rw-r--r--src/client/elm/Model/Action/LoggedInAction.elm21
-rw-r--r--src/client/elm/Model/View.elm4
-rw-r--r--src/client/elm/Model/View/LoggedInView.elm36
-rw-r--r--src/client/elm/Update.elm14
-rw-r--r--src/client/elm/Update/LoggedIn.elm135
-rw-r--r--src/client/elm/View.elm4
-rw-r--r--src/client/elm/View/LoggedIn.elm33
-rw-r--r--src/client/elm/View/LoggedIn/Account.elm37
-rw-r--r--src/client/elm/View/LoggedIn/AddPayment.elm29
-rw-r--r--src/client/elm/View/LoggedIn/Monthly.elm29
-rw-r--r--src/client/elm/View/LoggedIn/Paging.elm47
-rw-r--r--src/client/elm/View/LoggedIn/Table.elm35
17 files changed, 332 insertions, 324 deletions
diff --git a/src/client/elm/LoggedIn/Action.elm b/src/client/elm/LoggedIn/Action.elm
index e69de29..db69e2b 100644
--- a/src/client/elm/LoggedIn/Action.elm
+++ b/src/client/elm/LoggedIn/Action.elm
@@ -0,0 +1,21 @@
+module LoggedIn.Action
+ ( Action(..)
+ ) where
+
+import Model.Payment exposing (Payments, Payment, PaymentId, PaymentFrequency)
+import Model.Action.MonthlyAction exposing (MonthlyAction)
+import Model.Action.AccountAction exposing (AccountAction)
+import Model.Action.AddPaymentAction exposing (AddPaymentAction)
+
+type Action =
+ NoOp
+ | UpdateAdd AddPaymentAction
+ | UpdatePayments Payments
+ | AddPayment String String PaymentFrequency
+ | ValidateAddPayment PaymentId String Int PaymentFrequency
+ | DeletePayment Payment PaymentFrequency
+ | ValidateDeletePayment Payment PaymentFrequency
+ | ToggleEdit PaymentId
+ | UpdatePage Int
+ | UpdateMonthly MonthlyAction
+ | UpdateAccount AccountAction
diff --git a/src/client/elm/LoggedIn/Model.elm b/src/client/elm/LoggedIn/Model.elm
index e69de29..5ab5e01 100644
--- a/src/client/elm/LoggedIn/Model.elm
+++ b/src/client/elm/LoggedIn/Model.elm
@@ -0,0 +1,37 @@
+module LoggedIn.Model
+ ( Model
+ , init
+ ) where
+
+import Model.User exposing (Users, UserId)
+import Model.Payment exposing (Payments, PaymentFrequency(..))
+import Model.Payer exposing (Payers)
+import Model.Init exposing (..)
+
+import Model.View.LoggedIn.AddPayment exposing (..)
+import Model.View.LoggedIn.Edition exposing (..)
+import Model.View.LoggedIn.Monthly exposing (..)
+import Model.View.LoggedIn.Account exposing (..)
+
+type alias Model =
+ { users : Users
+ , add : AddPayment
+ , monthly : Monthly
+ , account : Account
+ , payments : Payments
+ , paymentsCount : Int
+ , paymentEdition : Maybe Edition
+ , currentPage : Int
+ }
+
+init : Init -> Model
+init initData =
+ { users = initData.users
+ , add = initAddPayment Punctual
+ , monthly = initMonthly initData.monthlyPayments
+ , account = initAccount initData.me initData.incomes
+ , payments = initData.payments
+ , paymentsCount = initData.paymentsCount
+ , paymentEdition = Nothing
+ , currentPage = 1
+ }
diff --git a/src/client/elm/LoggedIn/Update.elm b/src/client/elm/LoggedIn/Update.elm
index e69de29..aac046d 100644
--- a/src/client/elm/LoggedIn/Update.elm
+++ b/src/client/elm/LoggedIn/Update.elm
@@ -0,0 +1,136 @@
+module LoggedIn.Update
+ ( update
+ ) where
+
+import Date
+import Dict
+import Debug
+import Task
+import String
+
+import Effects exposing (Effects)
+import Http exposing (Error(..))
+
+import Server
+
+import LoggedIn.Action as LoggedInAction
+import LoggedIn.Model as LoggedInModel
+
+import Model exposing (Model)
+import Model.User exposing (UserId)
+import Model.Payment exposing (..)
+import Model.Action.AccountAction as Account
+import Model.Action.MonthlyAction as Monthly
+import Model.Action.AddPaymentAction as AddPayment
+import Model.View.LoggedIn.AddPayment exposing (..)
+import Model.Translations exposing (Translations, getMessage)
+
+import Update.LoggedIn.AddPayment exposing (updateAddPayment, addPaymentError)
+import Update.LoggedIn.Monthly exposing (updateMonthly)
+import Update.LoggedIn.Account exposing (updateAccount)
+
+update : Model -> LoggedInAction.Action -> LoggedInModel.Model -> (LoggedInModel.Model, Effects LoggedInAction.Action)
+update model action loggedInView =
+ case action of
+
+ LoggedInAction.NoOp -> (loggedInView, Effects.none)
+
+ LoggedInAction.UpdateAdd addPaymentAction ->
+ ( { loggedInView | add = updateAddPayment addPaymentAction loggedInView.add }
+ , Effects.none
+ )
+
+ LoggedInAction.UpdatePayments payments ->
+ ( { loggedInView | payments = payments }
+ , Effects.none
+ )
+
+ LoggedInAction.AddPayment name cost frequency ->
+ ( { loggedInView | add = updateAddPayment AddPayment.WaitingServer loggedInView.add }
+ , Server.addPayment name cost frequency
+ |> Task.map (\paymentId ->
+ case String.toInt cost of
+ Err _ ->
+ LoggedInAction.UpdateAdd (AddPayment.AddError Nothing (Just (getMessage "CostRequired" model.translations)))
+ Ok costNumber ->
+ LoggedInAction.ValidateAddPayment paymentId name costNumber frequency
+ )
+ |> flip Task.onError (\err ->
+ case err of
+ BadResponse 400 jsonErr ->
+ case addPaymentError model.translations jsonErr of
+ Just addPaymentAction -> Task.succeed (LoggedInAction.UpdateAdd addPaymentAction)
+ Nothing -> Task.succeed LoggedInAction.NoOp
+ _ ->
+ Task.succeed LoggedInAction.NoOp
+ )
+ |> Effects.task
+ )
+
+ LoggedInAction.ValidateAddPayment paymentId name cost frequency ->
+ let newPayment = Payment paymentId (Date.fromTime model.currentTime) name cost loggedInView.account.me
+ newAdd = initAddPayment frequency
+ in case frequency of
+ Punctual ->
+ ( { loggedInView
+ | currentPage = 1
+ , add = newAdd
+ , account = loggedInView.account
+ , payments = newPayment :: loggedInView.payments
+ , paymentsCount = loggedInView.paymentsCount + 1
+ }
+ , Effects.none
+ )
+ Monthly ->
+ ( { loggedInView
+ | add = newAdd
+ , monthly = updateMonthly (Monthly.AddPayment newPayment) loggedInView.monthly
+ }
+ , Effects.none
+ )
+
+ LoggedInAction.ToggleEdit id ->
+ ( { loggedInView | paymentEdition = if loggedInView.paymentEdition == Just id then Nothing else Just id }
+ , Effects.none
+ )
+
+ LoggedInAction.DeletePayment payment frequency ->
+ ( loggedInView
+ , Server.deletePayment payment frequency
+ |> Task.map (always (LoggedInAction.ValidateDeletePayment payment frequency))
+ |> flip Task.onError (always <| Task.succeed LoggedInAction.NoOp)
+ |> Effects.task
+ )
+
+ LoggedInAction.ValidateDeletePayment payment frequency ->
+ case frequency of
+ Monthly ->
+ ( { loggedInView
+ | monthly = updateMonthly (Monthly.DeletePayment payment) loggedInView.monthly
+ }
+ , Effects.none
+ )
+ Punctual ->
+ ( { loggedInView
+ | account = loggedInView.account
+ , payments = deletePayment payment.id loggedInView.payments
+ , paymentsCount = loggedInView.paymentsCount - 1
+ }
+ , Effects.none
+ )
+
+ LoggedInAction.UpdatePage page ->
+ ( { loggedInView | currentPage = page }
+ , Effects.none
+ )
+
+ LoggedInAction.UpdateMonthly monthlyAction ->
+ ( { loggedInView | monthly = updateMonthly monthlyAction loggedInView.monthly }
+ , Effects.none
+ )
+
+ LoggedInAction.UpdateAccount accountAction ->
+ let (newAccount, accountEffects) = updateAccount accountAction loggedInView.account
+ in ( { loggedInView | account = newAccount }
+ , Effects.map LoggedInAction.UpdateAccount accountEffects
+ )
diff --git a/src/client/elm/LoggedIn/View.elm b/src/client/elm/LoggedIn/View.elm
index e69de29..8d4bdbb 100644
--- a/src/client/elm/LoggedIn/View.elm
+++ b/src/client/elm/LoggedIn/View.elm
@@ -0,0 +1,34 @@
+module LoggedIn.View
+ ( view
+ ) where
+
+import Signal exposing (Address)
+
+import Html exposing (..)
+import Html.Attributes exposing (..)
+
+import LoggedIn.Model as LoggedInModel
+
+import Model exposing (Model)
+import Model.Payment exposing (Payments)
+import Model.Action exposing (Action)
+
+import View.LoggedIn.AddPayment exposing (addPayment)
+import View.LoggedIn.Monthly exposing (monthlyPayments)
+import View.LoggedIn.Account exposing (account)
+import View.LoggedIn.Table exposing (paymentsTable)
+import View.LoggedIn.Paging exposing (paymentsPaging)
+
+view : Address Action -> Model -> LoggedInModel.Model -> Html
+view address model loggedInModel =
+ div
+ [ class "loggedIn" ]
+ [ addPayment address model loggedInModel
+ , div
+ [ class "expandables" ]
+ [ account address model loggedInModel
+ , monthlyPayments address model loggedInModel
+ ]
+ , paymentsTable address model loggedInModel
+ , paymentsPaging address loggedInModel
+ ]
diff --git a/src/client/elm/Model/Action.elm b/src/client/elm/Model/Action.elm
index 3d06521..7c99f39 100644
--- a/src/client/elm/Model/Action.elm
+++ b/src/client/elm/Model/Action.elm
@@ -5,10 +5,10 @@ module Model.Action
import Time exposing (Time)
import Signal exposing (Address)
-import Model.Action.LoggedInAction exposing (LoggedInAction)
import Model.Init exposing (Init)
import SignIn.Action as SignInAction
+import LoggedIn.Action as LoggedInAction
type Action =
NoOp
@@ -16,6 +16,6 @@ type Action =
| UpdateTime Time
| GoLoggedInView Init
| UpdateSignIn SignInAction.Action
- | UpdateLoggedIn LoggedInAction
+ | UpdateLoggedIn LoggedInAction.Action
| GoSignInView
| SignOut
diff --git a/src/client/elm/Model/Action/LoggedInAction.elm b/src/client/elm/Model/Action/LoggedInAction.elm
deleted file mode 100644
index 4538ec7..0000000
--- a/src/client/elm/Model/Action/LoggedInAction.elm
+++ /dev/null
@@ -1,21 +0,0 @@
-module Model.Action.LoggedInAction
- ( LoggedInAction(..)
- ) where
-
-import Model.Payment exposing (Payments, Payment, PaymentId, PaymentFrequency)
-import Model.Action.MonthlyAction exposing (MonthlyAction)
-import Model.Action.AccountAction exposing (AccountAction)
-import Model.Action.AddPaymentAction exposing (AddPaymentAction)
-
-type LoggedInAction =
- NoOp
- | UpdateAdd AddPaymentAction
- | UpdatePayments Payments
- | AddPayment String String PaymentFrequency
- | ValidateAddPayment PaymentId String Int PaymentFrequency
- | DeletePayment Payment PaymentFrequency
- | ValidateDeletePayment Payment PaymentFrequency
- | ToggleEdit PaymentId
- | UpdatePage Int
- | UpdateMonthly MonthlyAction
- | UpdateAccount AccountAction
diff --git a/src/client/elm/Model/View.elm b/src/client/elm/Model/View.elm
index 7fc42af..9d64c73 100644
--- a/src/client/elm/Model/View.elm
+++ b/src/client/elm/Model/View.elm
@@ -3,11 +3,11 @@ module Model.View
) where
import Model.Payment exposing (Payments)
-import Model.View.LoggedInView exposing (..)
import SignIn.Model as SignInModel
+import LoggedIn.Model as LoggedInModel
type View =
LoadingView
| SignInView SignInModel.Model
- | LoggedInView LoggedInView
+ | LoggedInView LoggedInModel.Model
diff --git a/src/client/elm/Model/View/LoggedInView.elm b/src/client/elm/Model/View/LoggedInView.elm
deleted file mode 100644
index e33c58b..0000000
--- a/src/client/elm/Model/View/LoggedInView.elm
+++ /dev/null
@@ -1,36 +0,0 @@
-module Model.View.LoggedInView
- ( LoggedInView
- , initLoggedInView
- ) where
-
-import Model.User exposing (Users, UserId)
-import Model.Payment exposing (Payments, PaymentFrequency(..))
-import Model.Payer exposing (Payers)
-import Model.Init exposing (..)
-import Model.View.LoggedIn.AddPayment exposing (..)
-import Model.View.LoggedIn.Edition exposing (..)
-import Model.View.LoggedIn.Monthly exposing (..)
-import Model.View.LoggedIn.Account exposing (..)
-
-type alias LoggedInView =
- { users : Users
- , add : AddPayment
- , monthly : Monthly
- , account : Account
- , payments : Payments
- , paymentsCount : Int
- , paymentEdition : Maybe Edition
- , currentPage : Int
- }
-
-initLoggedInView : Init -> LoggedInView
-initLoggedInView init =
- { users = init.users
- , add = initAddPayment Punctual
- , monthly = initMonthly init.monthlyPayments
- , account = initAccount init.me init.incomes
- , payments = init.payments
- , paymentsCount = init.paymentsCount
- , paymentEdition = Nothing
- , currentPage = 1
- }
diff --git a/src/client/elm/Update.elm b/src/client/elm/Update.elm
index 8b443a0..d25b852 100644
--- a/src/client/elm/Update.elm
+++ b/src/client/elm/Update.elm
@@ -11,16 +11,16 @@ import Server
import Model exposing (Model)
import Model.Translations exposing (getMessage)
import Model.Action exposing (..)
-import Model.Action.LoggedInAction exposing (LoggedInAction)
import Model.View as V
-import Model.View.LoggedInView exposing (..)
+
+import LoggedIn.Model as LoggedInModel
+import LoggedIn.Action as LoggedInAction
+import LoggedIn.Update as LoggedInUpdate
import SignIn.Model as SignInModel
import SignIn.Action as SignInAction
import SignIn.Update as SignInUpdate
-import Update.LoggedIn exposing (updateLoggedIn)
-
import Utils.Http exposing (errorKey)
update : Action -> Model -> (Model, Effects Action)
@@ -41,7 +41,7 @@ update action model =
)
GoLoggedInView init ->
- ( { model | view = V.LoggedInView (initLoggedInView init) }
+ ( { model | view = V.LoggedInView (LoggedInModel.init init) }
, Effects.none
)
@@ -73,11 +73,11 @@ applySignIn model signInAction =
_ ->
model
-applyLoggedIn : Model -> LoggedInAction -> (Model, Effects Action)
+applyLoggedIn : Model -> LoggedInAction.Action -> (Model, Effects Action)
applyLoggedIn model loggedInAction =
case model.view of
V.LoggedInView loggedInView ->
- let (loggedInView, effects) = updateLoggedIn model loggedInAction loggedInView
+ let (loggedInView, effects) = LoggedInUpdate.update model loggedInAction loggedInView
in ( { model | view = V.LoggedInView loggedInView }
, Effects.map UpdateLoggedIn effects
)
diff --git a/src/client/elm/Update/LoggedIn.elm b/src/client/elm/Update/LoggedIn.elm
deleted file mode 100644
index 300c63a..0000000
--- a/src/client/elm/Update/LoggedIn.elm
+++ /dev/null
@@ -1,135 +0,0 @@
-module Update.LoggedIn
- ( updateLoggedIn
- ) where
-
-import Date
-import Dict
-import Debug
-import Task
-import String
-
-import Effects exposing (Effects)
-import Http exposing (Error(..))
-
-import Server
-
-import Model exposing (Model)
-import Model.User exposing (UserId)
-import Model.Payment exposing (..)
-import Model.Action.LoggedInAction exposing (..)
-import Model.Action.AccountAction as Account
-import Model.Action.MonthlyAction as Monthly
-import Model.Action.AddPaymentAction as AddPayment
-import Model.View.LoggedInView exposing (..)
-import Model.View.LoggedIn.AddPayment exposing (..)
-import Model.Translations exposing (Translations, getMessage)
-
-import Update.LoggedIn.AddPayment exposing (updateAddPayment, addPaymentError)
-import Update.LoggedIn.Monthly exposing (updateMonthly)
-import Update.LoggedIn.Account exposing (updateAccount)
-
-updateLoggedIn : Model -> LoggedInAction -> LoggedInView -> (LoggedInView, Effects LoggedInAction)
-updateLoggedIn model action loggedInView =
- case action of
-
- NoOp -> (loggedInView, Effects.none)
-
- UpdateAdd addPaymentAction ->
- ( { loggedInView | add = updateAddPayment addPaymentAction loggedInView.add }
- , Effects.none
- )
-
- UpdatePayments payments ->
- ( { loggedInView | payments = payments }
- , Effects.none
- )
-
- AddPayment name cost frequency ->
- ( { loggedInView | add = updateAddPayment AddPayment.WaitingServer loggedInView.add }
- , Server.addPayment name cost frequency
- |> Task.map (\paymentId ->
- case String.toInt cost of
- Err _ ->
- UpdateAdd (AddPayment.AddError Nothing (Just (getMessage "CostRequired" model.translations)))
- Ok costNumber ->
- ValidateAddPayment paymentId name costNumber frequency
- )
- |> flip Task.onError (\err ->
- case err of
- BadResponse 400 jsonErr ->
- case addPaymentError model.translations jsonErr of
- Just addPaymentAction -> Task.succeed (UpdateAdd addPaymentAction)
- Nothing -> Task.succeed NoOp
- _ ->
- Task.succeed NoOp
- )
- |> Effects.task
- )
-
- ValidateAddPayment paymentId name cost frequency ->
- let newPayment = Payment paymentId (Date.fromTime model.currentTime) name cost loggedInView.account.me
- newAdd = initAddPayment frequency
- in case frequency of
- Punctual ->
- ( { loggedInView
- | currentPage = 1
- , add = newAdd
- , account = loggedInView.account
- , payments = newPayment :: loggedInView.payments
- , paymentsCount = loggedInView.paymentsCount + 1
- }
- , Effects.none
- )
- Monthly ->
- ( { loggedInView
- | add = newAdd
- , monthly = updateMonthly (Monthly.AddPayment newPayment) loggedInView.monthly
- }
- , Effects.none
- )
-
- ToggleEdit id ->
- ( { loggedInView | paymentEdition = if loggedInView.paymentEdition == Just id then Nothing else Just id }
- , Effects.none
- )
-
- DeletePayment payment frequency ->
- ( loggedInView
- , Server.deletePayment payment frequency
- |> Task.map (always (ValidateDeletePayment payment frequency))
- |> flip Task.onError (always <| Task.succeed NoOp)
- |> Effects.task
- )
-
- ValidateDeletePayment payment frequency ->
- case frequency of
- Monthly ->
- ( { loggedInView
- | monthly = updateMonthly (Monthly.DeletePayment payment) loggedInView.monthly
- }
- , Effects.none
- )
- Punctual ->
- ( { loggedInView
- | account = loggedInView.account
- , payments = deletePayment payment.id loggedInView.payments
- , paymentsCount = loggedInView.paymentsCount - 1
- }
- , Effects.none
- )
-
- UpdatePage page ->
- ( { loggedInView | currentPage = page }
- , Effects.none
- )
-
- UpdateMonthly monthlyAction ->
- ( { loggedInView | monthly = updateMonthly monthlyAction loggedInView.monthly }
- , Effects.none
- )
-
- UpdateAccount accountAction ->
- let (newAccount, accountEffects) = updateAccount accountAction loggedInView.account
- in ( { loggedInView | account = newAccount }
- , Effects.map UpdateAccount accountEffects
- )
diff --git a/src/client/elm/View.elm b/src/client/elm/View.elm
index d29f814..081166d 100644
--- a/src/client/elm/View.elm
+++ b/src/client/elm/View.elm
@@ -11,9 +11,9 @@ import Model.View exposing (..)
import View.Header exposing (renderHeader)
import View.Loading exposing (renderLoading)
-import View.LoggedIn exposing (renderLoggedIn)
import SignIn.View as SignInView
+import LoggedIn.View as LoggedInView
view : Address Action -> Model -> Html
view address model =
@@ -31,4 +31,4 @@ renderMain address model =
SignInView signInView ->
SignInView.view address model signInView
LoggedInView loggedInView ->
- renderLoggedIn address model loggedInView
+ LoggedInView.view address model loggedInView
diff --git a/src/client/elm/View/LoggedIn.elm b/src/client/elm/View/LoggedIn.elm
deleted file mode 100644
index 69d1294..0000000
--- a/src/client/elm/View/LoggedIn.elm
+++ /dev/null
@@ -1,33 +0,0 @@
-module View.LoggedIn
- ( renderLoggedIn
- ) where
-
-import Signal exposing (Address)
-
-import Html exposing (..)
-import Html.Attributes exposing (..)
-
-import Model exposing (Model)
-import Model.Payment exposing (Payments)
-import Model.Action exposing (Action)
-import Model.View.LoggedInView exposing (LoggedInView)
-
-import View.LoggedIn.AddPayment exposing (addPayment)
-import View.LoggedIn.Monthly exposing (monthlyPayments)
-import View.LoggedIn.Account exposing (account)
-import View.LoggedIn.Table exposing (paymentsTable)
-import View.LoggedIn.Paging exposing (paymentsPaging)
-
-renderLoggedIn : Address Action -> Model -> LoggedInView -> Html
-renderLoggedIn address model loggedInView =
- div
- [ class "loggedIn" ]
- [ addPayment address model loggedInView
- , div
- [ class "expandables" ]
- [ account address model loggedInView
- , monthlyPayments address model loggedInView
- ]
- , paymentsTable address model loggedInView
- , paymentsPaging address loggedInView
- ]
diff --git a/src/client/elm/View/LoggedIn/Account.elm b/src/client/elm/View/LoggedIn/Account.elm
index 5bbf73e..66d8582 100644
--- a/src/client/elm/View/LoggedIn/Account.elm
+++ b/src/client/elm/View/LoggedIn/Account.elm
@@ -10,15 +10,16 @@ import Html as H exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
+import LoggedIn.Action as LoggedInAction
+import LoggedIn.Model as LoggedInModel
+
import Model exposing (Model)
import Model.User exposing (getUserName)
import Model.Payer exposing (..)
import Model.Translations exposing (getParamMessage, getMessage)
import Model.Action exposing (..)
-import Model.Action.LoggedInAction exposing (..)
import Model.Action.AccountAction exposing (..)
-import Model.View.LoggedInView exposing (LoggedInView)
import Model.View.LoggedIn.Account exposing (..)
import View.Expand exposing (..)
@@ -27,39 +28,39 @@ import View.Events exposing (onSubmitPrevDefault)
import Utils.Either exposing (toMaybeError)
-account : Address Action -> Model -> LoggedInView -> Html
-account address model loggedInView =
- let account = loggedInView.account
+account : Address Action -> Model -> LoggedInModel.Model -> Html
+account address model loggedInModel =
+ let account = loggedInModel.account
in div
[ classList
[ ("account", True)
, ("detail", account.visibleDetail)
]
]
- [ exceedingPayers address model loggedInView
+ [ exceedingPayers address model loggedInModel
, if account.visibleDetail
then income address model account
else text ""
]
-exceedingPayers : Address Action -> Model -> LoggedInView -> Html
-exceedingPayers address model loggedInView =
+exceedingPayers : Address Action -> Model -> LoggedInModel.Model -> Html
+exceedingPayers address model loggedInModel =
button
[ class "header"
- , onClick address (UpdateLoggedIn << UpdateAccount <| ToggleDetail)
+ , onClick address (UpdateLoggedIn << LoggedInAction.UpdateAccount <| ToggleDetail)
]
- ( (List.map (exceedingPayer model loggedInView) (getOrderedExceedingPayers model.currentTime loggedInView.users loggedInView.account.incomes loggedInView.payments))
- ++ [ expand ExpandDown loggedInView.account.visibleDetail ]
+ ( (List.map (exceedingPayer model loggedInModel) (getOrderedExceedingPayers model.currentTime loggedInModel.users loggedInModel.account.incomes loggedInModel.payments))
+ ++ [ expand ExpandDown loggedInModel.account.visibleDetail ]
)
-exceedingPayer : Model -> LoggedInView -> ExceedingPayer -> Html
-exceedingPayer model loggedInView payer =
+exceedingPayer : Model -> LoggedInModel.Model -> ExceedingPayer -> Html
+exceedingPayer model loggedInModel payer =
div
[ class "exceedingPayer" ]
[ span
[ class "userName" ]
[ payer.userId
- |> getUserName loggedInView.users
+ |> getUserName loggedInModel.users
|> Maybe.withDefault "−"
|> text
]
@@ -94,9 +95,9 @@ incomeEdition address model account edition =
H.form
[ case validateIncome edition.income model.translations of
Ok validatedAmount ->
- onSubmitPrevDefault address (UpdateLoggedIn << UpdateAccount <| UpdateIncome model.currentTime validatedAmount)
+ onSubmitPrevDefault address (UpdateLoggedIn << LoggedInAction.UpdateAccount <| UpdateIncome model.currentTime validatedAmount)
Err error ->
- onSubmitPrevDefault address (UpdateLoggedIn << UpdateAccount << UpdateEditionError <| error)
+ onSubmitPrevDefault address (UpdateLoggedIn << LoggedInAction.UpdateAccount << UpdateEditionError <| error)
, class "income"
]
[ label
@@ -105,7 +106,7 @@ incomeEdition address model account edition =
, input
[ id "incomeInput"
, value edition.income
- , on "input" targetValue (Signal.message address << UpdateLoggedIn << UpdateAccount << UpdateIncomeEdition)
+ , on "input" targetValue (Signal.message address << UpdateLoggedIn << LoggedInAction.UpdateAccount << UpdateIncomeEdition)
, maxlength 10
]
[]
@@ -125,6 +126,6 @@ toggleIncomeEdition address className name =
button
[ type' "button"
, class className
- , onClick address (UpdateLoggedIn << UpdateAccount <| ToggleIncomeEdition)
+ , onClick address (UpdateLoggedIn << LoggedInAction.UpdateAccount <| ToggleIncomeEdition)
]
[ text name ]
diff --git a/src/client/elm/View/LoggedIn/AddPayment.elm b/src/client/elm/View/LoggedIn/AddPayment.elm
index 7c0d34b..010ecd3 100644
--- a/src/client/elm/View/LoggedIn/AddPayment.elm
+++ b/src/client/elm/View/LoggedIn/AddPayment.elm
@@ -9,15 +9,16 @@ import Html as H exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
+import LoggedIn.Action as LoggedInAction
+import LoggedIn.Model as LoggedInModel
+
import Model exposing (Model)
import Model.Payment exposing (PaymentFrequency(..))
import Model.Translations exposing (getMessage)
import Model.Action as Action exposing (..)
-import Model.Action.LoggedInAction as LoggedInAction exposing (..)
import Model.Action.AddPaymentAction exposing (..)
import Model.View.LoggedIn.AddPayment exposing (..)
-import Model.View.LoggedInView exposing (LoggedInView)
import View.Events exposing (onSubmitPrevDefault)
import View.Icon exposing (..)
@@ -25,30 +26,30 @@ import View.Icon exposing (..)
import Utils.Maybe exposing (isJust)
import Utils.Either exposing (toMaybeError)
-addPayment : Address Action -> Model -> LoggedInView -> Html
-addPayment address model loggedInView =
+addPayment : Address Action -> Model -> LoggedInModel.Model -> Html
+addPayment address model loggedInModel =
H.form
[ let update =
- if loggedInView.add.waitingServer
+ if loggedInModel.add.waitingServer
then
Action.NoOp
else
- UpdateLoggedIn <| LoggedInAction.AddPayment loggedInView.add.name loggedInView.add.cost loggedInView.add.frequency
+ UpdateLoggedIn <| LoggedInAction.AddPayment loggedInModel.add.name loggedInModel.add.cost loggedInModel.add.frequency
in onSubmitPrevDefault address update
, class "addPayment"
]
- [ addPaymentName address loggedInView.add
- , addPaymentCost address model loggedInView.add
- , paymentFrequency address model loggedInView.add
+ [ addPaymentName address loggedInModel.add
+ , addPaymentCost address model loggedInModel.add
+ , paymentFrequency address model loggedInModel.add
, button
[ type' "submit"
, classList
[ ("add", True)
- , ("waitingServer", loggedInView.add.waitingServer)
+ , ("waitingServer", loggedInModel.add.waitingServer)
]
]
[ text (getMessage "Add" model.translations)
- , if loggedInView.add.waitingServer then renderSpinIcon else text ""
+ , if loggedInModel.add.waitingServer then renderSpinIcon else text ""
]
]
@@ -63,7 +64,7 @@ addPaymentName address addPayment =
[ input
[ id "nameInput"
, value addPayment.name
- , on "input" targetValue (Signal.message address << UpdateLoggedIn << UpdateAdd << UpdateName)
+ , on "input" targetValue (Signal.message address << UpdateLoggedIn << LoggedInAction.UpdateAdd << UpdateName)
, maxlength 20
]
[]
@@ -88,7 +89,7 @@ addPaymentCost address model addPayment =
[ input
[ id "costInput"
, value addPayment.cost
- , on "input" targetValue (Signal.message address << UpdateLoggedIn << UpdateAdd << UpdateCost)
+ , on "input" targetValue (Signal.message address << UpdateLoggedIn << LoggedInAction.UpdateAdd << UpdateCost)
, maxlength 7
]
[]
@@ -107,7 +108,7 @@ paymentFrequency address model addPayment =
button
[ type' "button"
, class "frequency"
- , onClick address (UpdateLoggedIn << UpdateAdd <| ToggleFrequency)
+ , onClick address (UpdateLoggedIn << LoggedInAction.UpdateAdd <| ToggleFrequency)
]
[ div
[ classList
diff --git a/src/client/elm/View/LoggedIn/Monthly.elm b/src/client/elm/View/LoggedIn/Monthly.elm
index 2e9ff1e..ae7e6bc 100644
--- a/src/client/elm/View/LoggedIn/Monthly.elm
+++ b/src/client/elm/View/LoggedIn/Monthly.elm
@@ -9,22 +9,23 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
+import LoggedIn.Action as LoggedInAction
+import LoggedIn.Model as LoggedInModel
+
import Model exposing (Model)
import Model.Payment as Payment exposing (Payments, Payment)
import Model.Translations exposing (getMessage, getParamMessage)
import Model.Action exposing (..)
-import Model.Action.LoggedInAction as LoggedInAction exposing (..)
import Model.Action.MonthlyAction exposing (..)
import Model.View.LoggedIn.Monthly exposing (Monthly)
-import Model.View.LoggedInView exposing (LoggedInView)
import View.Icon exposing (renderIcon)
import View.Expand exposing (..)
import View.Price exposing (price)
-monthlyPayments : Address Action -> Model -> LoggedInView -> Html
-monthlyPayments address model loggedInView =
- let monthly = loggedInView.monthly
+monthlyPayments : Address Action -> Model -> LoggedInModel.Model -> Html
+monthlyPayments address model loggedInModel =
+ let monthly = loggedInModel.monthly
in if List.length monthly.payments == 0
then
text ""
@@ -36,7 +37,7 @@ monthlyPayments address model loggedInView =
]
]
[ monthlyCount address model monthly
- , if monthly.visibleDetail then paymentsTable address model loggedInView monthly else text ""
+ , if monthly.visibleDetail then paymentsTable address model loggedInModel monthly else text ""
]
monthlyCount : Address Action -> Model -> Monthly -> Html
@@ -46,29 +47,29 @@ monthlyCount address model monthly =
key = if count > 1 then "PluralMonthlyCount" else "SingularMonthlyCount"
in button
[ class "header"
- , onClick address (UpdateLoggedIn << UpdateMonthly <| ToggleDetail)
+ , onClick address (UpdateLoggedIn << LoggedInAction.UpdateMonthly <| ToggleDetail)
]
[ text (getParamMessage [toString count, price model total] key model.translations)
, expand ExpandDown monthly.visibleDetail
]
-paymentsTable : Address Action -> Model -> LoggedInView -> Monthly -> Html
-paymentsTable address model loggedInView monthly =
+paymentsTable : Address Action -> Model -> LoggedInModel.Model -> Monthly -> Html
+paymentsTable address model loggedInModel monthly =
div
[ class "table" ]
( monthly.payments
|> List.sortBy (String.toLower << .name)
- |> List.map (paymentLine address model loggedInView)
+ |> List.map (paymentLine address model loggedInModel)
)
-paymentLine : Address Action -> Model -> LoggedInView -> Payment -> Html
-paymentLine address model loggedInView payment =
+paymentLine : Address Action -> Model -> LoggedInModel.Model -> Payment -> Html
+paymentLine address model loggedInModel payment =
a
[ classList
[ ("row", True)
- , ("edition", loggedInView.paymentEdition == Just payment.id)
+ , ("edition", loggedInModel.paymentEdition == Just payment.id)
]
- , onClick address (UpdateLoggedIn (ToggleEdit payment.id))
+ , onClick address (UpdateLoggedIn (LoggedInAction.ToggleEdit payment.id))
]
[ div [ class "cell category" ] [ text (payment.name) ]
, div
diff --git a/src/client/elm/View/LoggedIn/Paging.elm b/src/client/elm/View/LoggedIn/Paging.elm
index b722ee7..20396a6 100644
--- a/src/client/elm/View/LoggedIn/Paging.elm
+++ b/src/client/elm/View/LoggedIn/Paging.elm
@@ -8,9 +8,10 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
+import LoggedIn.Action as LoggedInAction
+import LoggedIn.Model as LoggedInModel
+
import Model.Action as Action exposing (..)
-import Model.Action.LoggedInAction exposing (..)
-import Model.View.LoggedInView exposing (..)
import Model.Payment exposing (perPage)
import View.Icon exposing (renderIcon)
@@ -18,23 +19,23 @@ import View.Icon exposing (renderIcon)
showedPages : Int
showedPages = 5
-paymentsPaging : Address Action -> LoggedInView -> Html
-paymentsPaging address loggedInView =
- let maxPage = ceiling (toFloat loggedInView.paymentsCount / toFloat perPage)
- pages = truncatePages loggedInView.currentPage [1..maxPage]
+paymentsPaging : Address Action -> LoggedInModel.Model -> Html
+paymentsPaging address loggedInModel =
+ let maxPage = ceiling (toFloat loggedInModel.paymentsCount / toFloat perPage)
+ pages = truncatePages loggedInModel.currentPage [1..maxPage]
in if maxPage == 1
then
text ""
else
div
[ class "pages" ]
- ( ( if loggedInView.currentPage > 1
- then [ firstPage address, previousPage address loggedInView ]
+ ( ( if loggedInModel.currentPage > 1
+ then [ firstPage address, previousPage address loggedInModel ]
else []
)
- ++ ( List.map (paymentsPage address loggedInView) pages)
- ++ ( if loggedInView.currentPage < maxPage
- then [ nextPage address loggedInView, lastPage address maxPage ]
+ ++ ( List.map (paymentsPage address loggedInModel) pages)
+ ++ ( if loggedInModel.currentPage < maxPage
+ then [ nextPage address loggedInModel, lastPage address maxPage ]
else []
)
)
@@ -57,23 +58,23 @@ firstPage : Address Action -> Html
firstPage address =
button
[ class "page"
- , onClick address (UpdateLoggedIn (UpdatePage 1))
+ , onClick address (UpdateLoggedIn (LoggedInAction.UpdatePage 1))
]
[ renderIcon "fast-backward" ]
-previousPage : Address Action -> LoggedInView -> Html
-previousPage address loggedInView =
+previousPage : Address Action -> LoggedInModel.Model -> Html
+previousPage address loggedInModel =
button
[ class "page"
- , onClick address (UpdateLoggedIn (UpdatePage (loggedInView.currentPage - 1)))
+ , onClick address (UpdateLoggedIn (LoggedInAction.UpdatePage (loggedInModel.currentPage - 1)))
]
[ renderIcon "backward" ]
-nextPage : Address Action -> LoggedInView -> Html
-nextPage address loggedInView =
+nextPage : Address Action -> LoggedInModel.Model -> Html
+nextPage address loggedInModel =
button
[ class "page"
- , onClick address (UpdateLoggedIn (UpdatePage (loggedInView.currentPage + 1)))
+ , onClick address (UpdateLoggedIn (LoggedInAction.UpdatePage (loggedInModel.currentPage + 1)))
]
[ renderIcon "forward" ]
@@ -81,19 +82,19 @@ lastPage : Address Action -> Int -> Html
lastPage address maxPage =
button
[ class "page"
- , onClick address (UpdateLoggedIn (UpdatePage maxPage))
+ , onClick address (UpdateLoggedIn (LoggedInAction.UpdatePage maxPage))
]
[ renderIcon "fast-forward" ]
-paymentsPage : Address Action -> LoggedInView -> Int -> Html
-paymentsPage address loggedInView page =
- let onCurrentPage = page == loggedInView.currentPage
+paymentsPage : Address Action -> LoggedInModel.Model -> Int -> Html
+paymentsPage address loggedInModel page =
+ let onCurrentPage = page == loggedInModel.currentPage
in button
[ classList
[ ("page", True)
, ("current", onCurrentPage)
]
, onClick address <|
- if onCurrentPage then Action.NoOp else UpdateLoggedIn (UpdatePage page)
+ if onCurrentPage then Action.NoOp else UpdateLoggedIn (LoggedInAction.UpdatePage page)
]
[ text (toString page) ]
diff --git a/src/client/elm/View/LoggedIn/Table.elm b/src/client/elm/View/LoggedIn/Table.elm
index 4c302a5..ababcbd 100644
--- a/src/client/elm/View/LoggedIn/Table.elm
+++ b/src/client/elm/View/LoggedIn/Table.elm
@@ -11,23 +11,24 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
+import LoggedIn.Action as LoggedInAction
+import LoggedIn.Model as LoggedInModel
+
import Model exposing (Model)
import Model.User exposing (getUserName)
import Model.Payment exposing (..)
import Model.Translations exposing (getMessage)
import Model.Action exposing (..)
-import Model.Action.LoggedInAction exposing (..)
-import Model.View.LoggedInView exposing (LoggedInView)
import View.Icon exposing (renderIcon)
import View.Date exposing (..)
import View.Price exposing (price)
-paymentsTable : Address Action -> Model -> LoggedInView -> Html
-paymentsTable address model loggedInView =
+paymentsTable : Address Action -> Model -> LoggedInModel.Model -> Html
+paymentsTable address model loggedInModel =
div
[ class "table" ]
- ( headerLine model :: paymentLines address model loggedInView)
+ ( headerLine model :: paymentLines address model loggedInModel)
headerLine : Model -> Html
headerLine model =
@@ -40,23 +41,23 @@ headerLine model =
, div [ class "cell" ] []
]
-paymentLines : Address Action -> Model -> LoggedInView -> List Html
-paymentLines address model loggedInView =
- loggedInView.payments
+paymentLines : Address Action -> Model -> LoggedInModel.Model -> List Html
+paymentLines address model loggedInModel =
+ loggedInModel.payments
|> List.sortBy (Date.toTime << .creation)
|> List.reverse
- |> List.drop ((loggedInView.currentPage - 1) * perPage)
+ |> List.drop ((loggedInModel.currentPage - 1) * perPage)
|> List.take perPage
- |> List.map (paymentLine address model loggedInView)
+ |> List.map (paymentLine address model loggedInModel)
-paymentLine : Address Action -> Model -> LoggedInView -> Payment -> Html
-paymentLine address model loggedInView payment =
+paymentLine : Address Action -> Model -> LoggedInModel.Model -> Payment -> Html
+paymentLine address model loggedInModel payment =
a
[ classList
[ ("row", True)
- , ("edition", loggedInView.paymentEdition == Just payment.id)
+ , ("edition", loggedInModel.paymentEdition == Just payment.id)
]
- , onClick address (UpdateLoggedIn (ToggleEdit payment.id))
+ , onClick address (UpdateLoggedIn (LoggedInAction.ToggleEdit payment.id))
]
[ div [ class "cell category" ] [ text payment.name ]
, div
@@ -69,7 +70,7 @@ paymentLine address model loggedInView payment =
, div
[ class "cell user" ]
[ payment.userId
- |> getUserName loggedInView.users
+ |> getUserName loggedInModel.users
|> Maybe.withDefault "−"
|> text
]
@@ -82,12 +83,12 @@ paymentLine address model loggedInView payment =
[ class "longDate" ]
[ text (renderLongDate payment.creation model.translations) ]
]
- , if loggedInView.account.me == payment.userId
+ , if loggedInModel.account.me == payment.userId
then
div
[ class "cell delete" ]
[ button
- [ onClick address (UpdateLoggedIn <| DeletePayment payment Punctual)]
+ [ onClick address (UpdateLoggedIn <| LoggedInAction.DeletePayment payment Punctual)]
[ renderIcon "times" ]
]
else