Skip to main content

PageFilter

Struct PageFilter 

Source
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

Source

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.

Source

pub fn date_range(key: impl Into<String>, label: impl Into<Text>) -> Self

A range of days, held in ?pf.<key>.from= and ?pf.<key>.to=. A day that does not parse reads as an open end.

Trait Implementations§

Source§

impl Clone for PageFilter

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more