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.
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | none | Turns pagination on or off. Set false on a resource to override the domain. |
type | :infinite | :numbered | :load_more | :load_more | The 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_size | integer | 20 | Records per page. It must be one of page_size_options when both are set. |
page_size_options | list(integer) | none (no page size selector) | Page sizes the reader can pick. Without a list, the page size selector is not drawn. |
max_page_size | pos_integer | 150 | The 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.
| Option | Type | Default | Description |
|---|---|---|---|
load_more_label | String.t | "Load More" | Load more button text. |
loading_text | String.t | "Loading..." | Loading indicator text. |
show_total | boolean | true | Shows 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_label | String.t | "Previous" | Previous page button text. |
next_label | String.t | "Next" | Next page button text. |
first_label | String.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_label | String.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_format | String.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.
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Enable 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. |
params | list(: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. |
prefix | String.t | none | Prefix for URL params. Overrides domain default. |
max_filter_length | pos_integer | 500 | The longest filter value read from the URL. Longer values are ignored. |
preserve_params | :all | list(atom) | none | Params 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.
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Enable realtime updates. |
pubsub | module | none | PubSub module. |
prefix | String.t | none | The topic prefix, for example "tag". Required whenever realtime is enabled. |
visible | (any, any -> any) | none | Decides, 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.
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Enable auto-refresh for this resource. Overrides domain default. |
interval | pos_integer | none | Refresh interval in milliseconds. Overrides domain default. |
pause_on_interaction | boolean | none | Pause 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_indicator | boolean | none | Show 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_blur | boolean | none | Pause 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. |