diff options
Diffstat (limited to 'src/client/View/Payments')
-rw-r--r-- | src/client/View/Payments/Add.elm | 14 | ||||
-rw-r--r-- | src/client/View/Payments/ExceedingPayer.elm | 14 | ||||
-rw-r--r-- | src/client/View/Payments/Paging.elm | 38 | ||||
-rw-r--r-- | src/client/View/Payments/Table.elm | 28 |
4 files changed, 47 insertions, 47 deletions
diff --git a/src/client/View/Payments/Add.elm b/src/client/View/Payments/Add.elm index 32233ed..77d40ea 100644 --- a/src/client/View/Payments/Add.elm +++ b/src/client/View/Payments/Add.elm @@ -17,7 +17,7 @@ import Update.Payment.Add exposing (..) import Model exposing (Model) import Model.View.Payment.Add exposing (..) import Model.Translations exposing (getMessage) -import Model.View.PaymentView exposing (PaymentView) +import Model.View.LoggedView exposing (LoggedView) import View.Events exposing (onSubmitPrevDefault) import View.Icon exposing (renderIcon) @@ -25,18 +25,18 @@ import View.Icon exposing (renderIcon) import Utils.Maybe exposing (isJust) import Utils.Either exposing (toMaybeError) -addPayment : Model -> PaymentView -> Html -addPayment model paymentView = +addPayment : Model -> LoggedView -> Html +addPayment model loggedView = H.form [ class "add" - , case (validateName paymentView.add.name model.translations, validateCost paymentView.add.cost model.translations) of + , case (validateName loggedView.add.name model.translations, validateCost loggedView.add.cost model.translations) of (Ok name, Ok cost) -> - onSubmitPrevDefault serverCommunications.address (SC.AddPayment paymentView.me name cost) + onSubmitPrevDefault serverCommunications.address (SC.AddPayment loggedView.me name cost) (resName, resCost) -> onSubmitPrevDefault actions.address (UpdatePayment <| UpdateAdd <| AddError (toMaybeError resName) (toMaybeError resCost)) ] - [ addPaymentName paymentView.add - , addPaymentCost model paymentView.add + [ addPaymentName loggedView.add + , addPaymentCost model loggedView.add , button [ type' "submit" ] [ text (getMessage "Add" model.translations)] diff --git a/src/client/View/Payments/ExceedingPayer.elm b/src/client/View/Payments/ExceedingPayer.elm index f249383..88b3a72 100644 --- a/src/client/View/Payments/ExceedingPayer.elm +++ b/src/client/View/Payments/ExceedingPayer.elm @@ -9,23 +9,23 @@ import List import Model exposing (Model) import Model.User exposing (getUserName) import Model.Payers exposing (..) -import Model.View.PaymentView exposing (PaymentView) +import Model.View.LoggedView exposing (LoggedView) import Model.Translations exposing (getMessage) -exceedingPayers : Model -> PaymentView -> Html -exceedingPayers model paymentView = +exceedingPayers : Model -> LoggedView -> Html +exceedingPayers model loggedView = div [ class "exceedingPayers" ] - (List.map (exceedingPayer model paymentView) (getOrderedExceedingPayers paymentView.payers)) + (List.map (exceedingPayer model loggedView) (getOrderedExceedingPayers loggedView.payers)) -exceedingPayer : Model -> PaymentView -> ExceedingPayer -> Html -exceedingPayer model paymentView payer = +exceedingPayer : Model -> LoggedView -> ExceedingPayer -> Html +exceedingPayer model loggedView payer = div [ class "exceedingPayer" ] [ span [ class "userName" ] [ payer.userId - |> getUserName paymentView.users + |> getUserName loggedView.users |> Maybe.withDefault "−" |> text ] diff --git a/src/client/View/Payments/Paging.elm b/src/client/View/Payments/Paging.elm index c3db819..b06d749 100644 --- a/src/client/View/Payments/Paging.elm +++ b/src/client/View/Payments/Paging.elm @@ -6,7 +6,7 @@ import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) -import Model.View.PaymentView exposing (..) +import Model.View.LoggedView exposing (..) import Model.Payment exposing (perPage) import ServerCommunication as SC exposing (serverCommunications) @@ -19,23 +19,23 @@ import View.Icon exposing (renderIcon) showedPages : Int showedPages = 5 -paymentsPaging : PaymentView -> Html -paymentsPaging paymentView = - let maxPage = ceiling (toFloat paymentView.paymentsCount / toFloat perPage) - pages = truncatePages paymentView.currentPage [1..maxPage] +paymentsPaging : LoggedView -> Html +paymentsPaging loggedView = + let maxPage = ceiling (toFloat loggedView.paymentsCount / toFloat perPage) + pages = truncatePages loggedView.currentPage [1..maxPage] in if maxPage == 1 then text "" else ul [ class "pages" ] - ( ( if paymentView.currentPage > 1 - then [ firstPage, previousPage paymentView ] + ( ( if loggedView.currentPage > 1 + then [ firstPage, previousPage loggedView ] else [] ) - ++ ( List.map (paymentsPage paymentView) pages) - ++ ( if paymentView.currentPage < maxPage - then [ nextPage paymentView, lastPage maxPage ] + ++ ( List.map (paymentsPage loggedView) pages) + ++ ( if loggedView.currentPage < maxPage + then [ nextPage loggedView, lastPage maxPage ] else [] ) ) @@ -62,19 +62,19 @@ firstPage = ] [ renderIcon "fast-backward" ] -previousPage : PaymentView -> Html -previousPage paymentView = +previousPage : LoggedView -> Html +previousPage loggedView = li [ class "page" - , onClick serverCommunications.address (SC.UpdatePage (paymentView.currentPage - 1)) + , onClick serverCommunications.address (SC.UpdatePage (loggedView.currentPage - 1)) ] [ renderIcon "backward" ] -nextPage : PaymentView -> Html -nextPage paymentView = +nextPage : LoggedView -> Html +nextPage loggedView = li [ class "page" - , onClick serverCommunications.address (SC.UpdatePage (paymentView.currentPage + 1)) + , onClick serverCommunications.address (SC.UpdatePage (loggedView.currentPage + 1)) ] [ renderIcon "forward" ] @@ -86,9 +86,9 @@ lastPage maxPage = ] [ renderIcon "fast-forward" ] -paymentsPage : PaymentView -> Int -> Html -paymentsPage paymentView page = - let onCurrentPage = page == paymentView.currentPage +paymentsPage : LoggedView -> Int -> Html +paymentsPage loggedView page = + let onCurrentPage = page == loggedView.currentPage in li [ class ("page" ++ (if onCurrentPage then " current" else "")) , onClick serverCommunications.address <| diff --git a/src/client/View/Payments/Table.elm b/src/client/View/Payments/Table.elm index 743a8a9..5374c44 100644 --- a/src/client/View/Payments/Table.elm +++ b/src/client/View/Payments/Table.elm @@ -15,7 +15,7 @@ import String exposing (append) import Model exposing (Model) import Model.User exposing (getUserName) import Model.Payment exposing (..) -import Model.View.PaymentView exposing (PaymentView) +import Model.View.LoggedView exposing (LoggedView) import Model.Translations exposing (getMessage) import ServerCommunication as SC exposing (serverCommunications) @@ -26,8 +26,8 @@ import Update.Payment exposing (..) import View.Icon exposing (renderIcon) import View.Date exposing (..) -paymentsTable : Model -> PaymentView -> Html -paymentsTable model paymentView = +paymentsTable : Model -> LoggedView -> Html +paymentsTable model loggedView = div [ class "table" ] ([ div @@ -38,20 +38,20 @@ paymentsTable model paymentView = , div [ class "cell date" ] [ renderIcon "calendar" ] , div [ class "cell" ] [] ] - ] ++ (paymentLines model paymentView)) + ] ++ (paymentLines model loggedView)) -paymentLines : Model -> PaymentView -> List Html -paymentLines model paymentView = - paymentView.payments +paymentLines : Model -> LoggedView -> List Html +paymentLines model loggedView = + loggedView.payments |> Dict.toList |> List.sortBy (\(_, payment) -> Date.toTime payment.creation) |> List.reverse - |> List.map (paymentLine model paymentView) + |> List.map (paymentLine model loggedView) -paymentLine : Model -> PaymentView -> PaymentWithId -> Html -paymentLine model paymentView (id, payment) = +paymentLine : Model -> LoggedView -> PaymentWithId -> Html +paymentLine model loggedView (id, payment) = a - [ class ("row " ++ (if paymentView.edition == Just id then "edition" else "")) + [ class ("row " ++ (if loggedView.edition == Just id then "edition" else "")) , onClick actions.address (UpdatePayment (ToggleEdit id)) ] [ div [ class "cell category" ] [ text payment.name ] @@ -59,7 +59,7 @@ paymentLine model paymentView (id, payment) = , div [ class "cell user" ] [ payment.userId - |> getUserName paymentView.users + |> getUserName loggedView.users |> Maybe.withDefault "−" |> text ] @@ -72,11 +72,11 @@ paymentLine model paymentView (id, payment) = [ class "longDate" ] [ text (renderLongDate payment.creation model.translations) ] ] - , if paymentView.me == payment.userId + , if loggedView.me == payment.userId then div [ class "cell remove" - , onClick serverCommunications.address (SC.DeletePayment id payment.userId payment.cost paymentView.currentPage) + , onClick serverCommunications.address (SC.DeletePayment id payment.userId payment.cost loggedView.currentPage) ] [ renderIcon "times" ] else |