pub struct SelectFilter<M> { /* private fields */ }Expand description
Select filter matching a field exactly: a String, any FormScalar such as an Options
enum, or a foreign key to a relationship’s rows. Several values match
a record holding any of them, which multiple lets the control choose.
SelectFilter::new(lens!(Post.kind), ["news", "review"]);
SelectFilter::of(lens!(Post.status)).multiple();Implementations§
Source§impl<M> SelectFilter<M>
impl<M> SelectFilter<M>
Sourcepub fn new<T>(
lens: impl Into<Path<M, T>>,
options: impl IntoOptions,
) -> SelectFilter<M>
pub fn new<T>( lens: impl Into<Path<M, T>>, options: impl IntoOptions, ) -> SelectFilter<M>
Filter the field lens binds to one of options, each value in the field type’s form
spelling. Over a foreign key with no options, it applies any key the field parses, which
shows whether a row outside the source’s scoped query holds that key:
relationship checks the key against its source.
Sourcepub fn relationship<R>(
lens: Lens<M, impl Sized, impl FilterKey>,
) -> SelectFilter<M>where
R: OptionSource,
pub fn relationship<R>(
lens: Lens<M, impl Sized, impl FilterKey>,
) -> SelectFilter<M>where
R: OptionSource,
Filter the foreign key lens binds to one of the rows of the related source R, each
valued by its primary key and labelled by the source’s label, as
a form’s relationship choice offers them.
The control lists at most
MAX_RELATIONSHIP_OPTIONS rows of the
source’s scoped_query; past the cap, or when the source
refuses the load, it lists the chosen keys alone. The filter applies only the keys of those
rows, checked past the cap in one query; the table ignores another key as it ignores one no
row holds.
use tablo_core::{SelectFilter, lens};
SelectFilter::relationship::<AuthorResource>(lens!(Post.author_id)).label("Author");A form’s relationship choice loads the same rows the same way, so its loader is reused:
the rows of the source’s scoped query, at most
MAX_RELATIONSHIP_OPTIONS of them. Past that cap, or
when the source refuses the load, the control lists only the chosen keys.
It applies only the keys of those rows: within the cap, the keys its options list; past
it, the keys one query through the source’s scoped query returns.
Another key is ignored as one no row holds: the list warns and the export answers 400.
new or of over a foreign key checks no source, so it does not
hide that a key links to a row outside the source’s scoped query.
Sourcepub fn of<T>(lens: impl Into<Path<M, T>>) -> SelectFilter<M>
pub fn of<T>(lens: impl Into<Path<M, T>>) -> SelectFilter<M>
Filter the field lens binds to one of its Options type’s options.
Sourcepub fn options(&self) -> &[(String, Text)]
pub fn options(&self) -> &[(String, Text)]
The (value, label) options in declaration order; a relationship filter’s load per
request.
Sourcepub fn label(self, label: impl Into<Text>) -> SelectFilter<M>
pub fn label(self, label: impl Into<Text>) -> SelectFilter<M>
The label the control renders, over the field’s.
Sourcepub fn multiple(self) -> SelectFilter<M>
pub fn multiple(self) -> SelectFilter<M>
Choose several options: the control is a checklist, and the filter keeps the records holding any checked value.
Trait Implementations§
Source§impl<M> Clone for SelectFilter<M>
impl<M> Clone for SelectFilter<M>
Source§fn clone(&self) -> SelectFilter<M>
fn clone(&self) -> SelectFilter<M>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<M> Debug for SelectFilter<M>
impl<M> Debug for SelectFilter<M>
Source§impl<M> Filter<M> for SelectFilter<M>
impl<M> Filter<M> for SelectFilter<M>
Source§fn to_expr(&self, _cx: &Cx, value: &FilterValue) -> Option<Expr<bool>>
fn to_expr(&self, _cx: &Cx, value: &FilterValue) -> Option<Expr<bool>>
Any of the values, each listed and parsed by the field’s type; None when one is not, or
when the value names a part.
Source§fn control<'a>(&self, cx: &'a Cx, input: FilterInput) -> Pin<Box<dyn View + 'a>>
fn control<'a>(&self, cx: &'a Cx, input: FilterInput) -> Pin<Box<dyn View + 'a>>
A select over the options, or a checklist when the filter is
multiple.
Source§fn load_control<'s, 'a>(
&'s self,
cx: &'a Cx,
input: FilterInput,
) -> Pin<Box<dyn Future<Output = Pin<Box<dyn View + 'a>>> + Send + 's>>where
'a: 's,
fn load_control<'s, 'a>(
&'s self,
cx: &'a Cx,
input: FilterInput,
) -> Pin<Box<dyn Future<Output = Pin<Box<dyn View + 'a>>> + Send + 's>>where
'a: 's,
The control over the relationship’s rows, once they have loaded.
Source§fn is_noop_value(&self, _value: &FilterValue) -> bool
fn is_noop_value(&self, _value: &FilterValue) -> bool
value selects no predicate without being invalid.