diff options
Diffstat (limited to 'src/client/View')
-rw-r--r-- | src/client/View/Payments.elm | 2 | ||||
-rw-r--r-- | src/client/View/Payments/Paging.elm | 31 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/client/View/Payments.elm b/src/client/View/Payments.elm index c38cc18..3c9c09d 100644 --- a/src/client/View/Payments.elm +++ b/src/client/View/Payments.elm @@ -12,6 +12,7 @@ import Model.View.PaymentView exposing (PaymentView) import View.Payments.ExceedingPayer exposing (exceedingPayers) import View.Payments.Add exposing (addPayment) import View.Payments.Table exposing (paymentsTable) +import View.Payments.Paging exposing (paymentsPaging) renderPayments : Model -> PaymentView -> Html renderPayments model paymentView = @@ -20,4 +21,5 @@ renderPayments model paymentView = [ exceedingPayers model paymentView , addPayment model paymentView.add , paymentsTable model paymentView + , paymentsPaging paymentView ] diff --git a/src/client/View/Payments/Paging.elm b/src/client/View/Payments/Paging.elm new file mode 100644 index 0000000..7be4c7b --- /dev/null +++ b/src/client/View/Payments/Paging.elm @@ -0,0 +1,31 @@ +module View.Payments.Paging + ( paymentsPaging + ) where + +import Html exposing (..) +import Html.Attributes exposing (..) +import Html.Events exposing (..) + +import Model.View.PaymentView exposing (..) +import Model.Payment exposing (perPage) + +import ServerCommunication as SC exposing (serverCommunications) + +import Update exposing (..) +import Update.Payment exposing (..) + +paymentsPaging : PaymentView -> Html +paymentsPaging paymentView = + let maxPage = ceiling (toFloat paymentView.paymentsCount / toFloat perPage) + pages = [1..maxPage] + in ul + [ class "pages" ] + ( pages + |> List.map (\page -> + li + [ class ("page" ++ (if page == paymentView.currentPage then " current" else "")) + , onClick serverCommunications.address (SC.UpdatePage page) + ] + [ text (toString page) ] + ) + ) |