aboutsummaryrefslogtreecommitdiff
path: root/src/client/View/Payments/Paging.elm
blob: 7be4c7b64bd28edd5e1b21ad1c4de6810c090890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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) ]
               )
        )