aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/View/LoggedIn
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/View/LoggedIn')
-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
5 files changed, 91 insertions, 86 deletions
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