DataProvider.Pagination (DataProvider v1.2.1) View Source

Pagination module provides struct with actual pagination data for current DataProvider

Fields

Link to this section Summary

Functions

Creates new DataProvider.Pagination struct with received params.

Creates list of DataProvider.Pagination.Page by received total count and current page.

Calculates end position for received pagination.

Returns current page value of DataProvider by DataProvider.Pagination

Changes the value of field page

Changes the value of field page_size

Returns count of items, which gonna be put load into DataProvider.Data

Calculates starting position for received pagination.

Link to this section Types

Specs

t() :: %DataProvider.Pagination{
  page: integer(),
  pages: [DataProvider.Pagination.Page.t()],
  params: DataProvider.Pagination.Params.t()
}

Schema of DataProvider.Pagination.

Contains:

  • page - Current page of dataprovider.

  • pages - Pages which loaded for current pagination

  • page_size - count of items in one page of data provider.

Link to this section Functions

Specs

create(map()) :: t()

Creates new DataProvider.Pagination struct with received params.

Link to this function

create_page_list(pagination, total_count \\ 0)

View Source

Specs

create_page_list(t(), integer()) :: t()

Creates list of DataProvider.Pagination.Page by received total count and current page.

Arguments

  1. DataProvider.Pagination struct

  2. Total count of items

Returns

Function returns DataProvider.Pagination which :pages field is fill

%DataProvider.Pagination{
  ...
  pages: [
    ...
    %DataProvider.Pagination.Page{},
    %DataProvider.Pagination.Page{},
    %DataProvider.Pagination.Page{},
    ...
  ]
  ...
}

Options

Options, that can affect result of this function

:pages_ahead - The maximum count of pages, which will be loaded ahead of current position.

:pages_behind - The maximum count of pages, which will be loaded behind of current position.

:load_first_page? - Boolean value which indicates requirement of loading the first page in list.

:load_last_page? - Boolean value which indicates requirement of loading the last page in list.

:load_opening_separator? - Boolean value which indicates requirement of loading the separator page in list.

:load_closing_separator? - Boolean value which indicates requirement of loading the separator page in list.

Link to this function

end_position(pagination)

View Source

Specs

end_position(t()) :: integer()

Calculates end position for received pagination.

Requires for calculating selection limit in list of data.

Specs

page(t()) :: integer()

Returns current page value of DataProvider by DataProvider.Pagination

Link to this function

put_page(pagination, page)

View Source

Specs

put_page(t(), integer()) :: t()

Changes the value of field page

Link to this function

put_params(schema, params)

View Source

Specs

put_params(t(), map()) :: t()

Changes the value of field page_size

Link to this function

selection_limit(pagination)

View Source

Specs

selection_limit(t()) :: integer()

Returns count of items, which gonna be put load into DataProvider.Data

Link to this function

start_position(pagination)

View Source

Specs

start_position(t()) :: integer()

Calculates starting position for received pagination.

Requires for calculating start position in list of data or offset in query condition