pub struct ComputedColumn<M> { /* private fields */ }Expand description
A display-only column rendering any text from the row, with no query predicate.
tablo_core::ComputedColumn::new("Words", |p: &Post| {
p.body.split_whitespace().count().to_string()
});A closure that reads a relation declares it with include_unscoped,
so the page loads it. One relation’s record or count is a
RelationColumn or a CountColumn, which
declare their own and show only what the related resource shows the user.
It maps to no column, so it neither searches nor sorts.
Implementations§
Source§impl<M> ComputedColumn<M>where
M: Model,
impl<M> ComputedColumn<M>where
M: Model,
Sourcepub fn new(
label: impl Into<Text>,
project: impl Fn(&M) -> String + Send + Sync + 'static,
) -> Self
pub fn new( label: impl Into<Text>, project: impl Fn(&M) -> String + Send + Sync + 'static, ) -> Self
Declare a column headed label rendering project(row), named after the label: its
plain text in lowercase, or its message’s id.
Sourcepub fn include_unscoped<T>(self, relation: impl Into<Include<M, T>>) -> Self
pub fn include_unscoped<T>(self, relation: impl Into<Include<M, T>>) -> Self
Declare a relation the projection reads, so the table loads it. The projection reads
whatever the include loads, under no resource’s query or policy, as an
unscoped relation column does: another tenant’s record,
or one the user may not view, reaches it.
Sourcepub fn reading(self, reads: Reads<M>) -> Self
pub fn reading(self, reads: Reads<M>) -> Self
Declare the fields the projection reads, which a resource restricting a field with
field_access needs: the column shows only to a user
who may view every one.
Sourcepub fn width(self, width: ColumnWidth) -> Self
pub fn width(self, width: ColumnWidth) -> Self
Declare this column’s width.
Sourcepub fn toggleable(self) -> Self
pub fn toggleable(self) -> Self
Let each reader hide this column from their list; it starts shown.
Let each reader show this column in their list; it starts hidden.
Trait Implementations§
Source§impl<M> Clone for ComputedColumn<M>
impl<M> Clone for ComputedColumn<M>
Source§impl<M> Column<M> for ComputedColumn<M>
impl<M> Column<M> for ComputedColumn<M>
Source§fn column_width(&self) -> ColumnWidth
fn column_width(&self) -> ColumnWidth
Source§fn toggle(&self) -> ColumnToggle
fn toggle(&self) -> ColumnToggle
Source§fn is_searchable(&self) -> bool
fn is_searchable(&self) -> bool
Source§fn search_expr(&self, _term: &str) -> Option<Expr<bool>>
fn search_expr(&self, _term: &str) -> Option<Expr<bool>>
term adds.