pub struct PageFilter { /* private fields */ }Expand description
A value a page offers above its widgets and keeps in its query string, which its widgets read
through page_filters: the period a dashboard’s figures cover, or the
store they count.
A select holds ?pf.<key>=<value>, one of its options; a date range holds ?pf.<key>.from=
and ?pf.<key>.to=, each a YYYY-MM-DD day. The pf. prefix keeps them apart from a table’s
f. filters on the same page. The bar is a form the page submits to itself, carrying the
request’s other parameters, so a filtered dashboard is a link, a table on it keeps its search
and sort, and it works without JavaScript.
A page filter narrows nothing by itself: each widget decides what a value means, and still
reads its records through scoped_query or
list_query, so a value cannot widen what the request may see.
use tablo_core::{Page, PageDef, PageFilter};
struct SalesPage;
impl Page for SalesPage {
fn declare() -> PageDef {
PageDef::new()
.filter(PageFilter::date_range("period", "Period"))
.filter(PageFilter::select(
"channel",
"Channel",
[("web", "Web"), ("store", "Store")],
))
}
}Implementations§
Source§impl PageFilter
impl PageFilter
Sourcepub fn select(
key: impl Into<String>,
label: impl Into<Text>,
options: impl IntoOptions,
) -> Self
pub fn select( key: impl Into<String>, label: impl Into<Text>, options: impl IntoOptions, ) -> Self
A select over options, held in ?pf.<key>=: values that are their own label, (value, label) pairs, or a #[derive(Options)] enum’s options. A value naming
no option reads as none.