Table pagination and updates DSL

v0.0.1

The pagination, url_sync, realtime and refresh sections of a resource's table block control how pages load and how the table stays current. Each takes the value from the domain for a key you leave out. See Domain DSL.

pagination

Pagination style and sizes. Declare it inline (pagination type: :infinite, page_size: 25) or as a block. It sits at mishka_gervaz.table.pagination.

OptionTypeDefaultDescription
enabledbooleannoneTurns pagination on or off. Set false on a resource to override the domain.
type:infinite | :numbered | :load_more:load_moreThe pagination style: :numbered (pages), :load_more (a button) or :infinite (loads on scroll). The schema text names :load_more as the default. A domain pagination block without a type gives :load_more, and a resource pagination block without a type, in a domain with no pagination block, gives :numbered. Set it yourself.
page_sizeinteger20Records per page. It must be one of page_size_options when both are set.
page_size_optionslist(integer)none (no page size selector)Page sizes the reader can pick. Without a list, the page size selector is not drawn.
max_page_sizepos_integer150The largest allowed page size. It clamps a page size that arrives in the URL, and it must be at least the largest entry of page_size_options.

pagination ui

Labels and options of the pagination controls. It sits at mishka_gervaz.table.pagination.ui.

OptionTypeDefaultDescription
load_more_labelString.t"Load More"Load more button text.
loading_textString.t"Loading..."Loading indicator text.
show_totalbooleantrueShows the total record count. A :numbered table counts whatever this says. For :load_more and :infinite, turn it off to skip the count query on a data layer that cannot count.
prev_labelString.t"Previous"Previous page button text.
next_labelString.t"Next"Next page button text.
first_labelString.t"First"First page button text. The value is compiled into the config, but no built-in template or handler reads it. The pager has no First button.
last_labelString.t"Last"Last page button text. The value is compiled into the config, but no built-in template or handler reads it. The pager has no Last button.
page_info_formatString.t"Page {page} of {total}"The page info text. Placeholders: {page}, {total} and {count}. Gervaz prints {from} and {to} as they are.

url_sync

Round-trips table state through the URL. It sits at mishka_gervaz.table.url_sync.

OptionTypeDefaultDescription
enabledbooleantrueEnable URL state synchronization. Overrides domain default.
mode:read_only | :bidirectional:read_only:read_only (the default) never writes the URL. The table still reads it again whenever the parent passes a new url_state. :bidirectional also updates the URL when the filters, the sort or the page change.
paramslist(:filters | :sort | :page | :page_size | :search | :template)none (domain: [:filters, :sort, :page])Which state to sync to URL params. Overrides domain default. Listing :template writes it to the URL, but Gervaz does not read it back.
prefixString.tnonePrefix for URL params. Overrides domain default.
max_filter_lengthpos_integer500The longest filter value read from the URL. Longer values are ignored.
preserve_params:all | list(atom)noneParams the URL keeps when Gervaz rewrites it. :all keeps every unknown param, or give a list of names. Gervaz keeps them in state.preserved_params, and max_filter_length applies to their values.

realtime

PubSub-driven live updates. Declare it inline (realtime prefix: "posts") or as a block. It sits at mishka_gervaz.table.realtime.

OptionTypeDefaultDescription
enabledbooleantrueEnable realtime updates.
pubsubmodulenonePubSub module.
prefixString.tnoneThe topic prefix, for example "tag". Required whenever realtime is enabled.
visible(any, any -> any)noneDecides, for a user who is not a master, whether an incoming record is inserted: fn record, user -> boolean. A master always passes. A function replaces the default check, which compares the record's tenant attribute with the user's.

refresh

Reloads the table on a timer. It sits at mishka_gervaz.table.refresh.

OptionTypeDefaultDescription
enabledbooleantrueEnable auto-refresh for this resource. Overrides domain default.
intervalpos_integernoneRefresh interval in milliseconds. Overrides domain default.
pause_on_interactionbooleannonePause auto-refresh when user is interacting. Overrides domain default. The value is compiled into the config, but no built-in template or handler reads it.
show_indicatorbooleannoneShow visual indicator when auto-refresh is active. Overrides domain default. The value is compiled into the config, but no built-in template or handler reads it.
pause_on_blurbooleannonePause auto-refresh when browser tab loses focus. Overrides domain default. The value is compiled into the config, but no built-in template or handler reads it.