#[non_exhaustive]pub struct ListConfig {Show 20 fields
pub entity: String,
pub title: Text,
pub columns: Vec<ListColumn>,
pub order_by: String,
pub order_dir: SortDir,
pub per_page: i64,
pub id_field: String,
pub edit_base: Option<String>,
pub creatable: bool,
pub filters: Vec<ListFilter>,
pub deletable: bool,
pub exportable: bool,
pub reorder: Option<ReorderConfig>,
pub tree: Option<TreeConfig>,
pub toolbar: Vec<ToolbarButton>,
pub search: SearchConfig,
pub per_page_options: Vec<i64>,
pub no_records_message: Option<Text>,
pub row_click: RowClick,
pub remember: bool,
/* private fields */
}Expand description
A list view descriptor: which table, which columns, default ordering, page size, and (optionally) where per-row edit links point.
Built with ListConfig::new plus its builder methods. Non-exhaustive, so a
struct literal outside this crate cannot freeze the field set at 1.0; that
rules out ..Default::default() too, which is why the builders exist.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.entity: String§title: TextThe screen title, localized at render. Serde stays a plain string.
columns: Vec<ListColumn>§order_by: String§order_dir: SortDir§per_page: i64§id_field: String§edit_base: Option<String>When set, rows link to {edit_base}/{id}/edit.
creatable: boolWhether to offer a “New” link to {edit_base}/new. A resource that only
edits existing records (no create screen) sets this false.
filters: Vec<ListFilter>Filters offered above the table. Empty hides the bar.
deletable: boolWhether rows can be selected and deleted from this list. Off by default: a list that shows a log, or records another screen owns, has no business offering it.
exportable: boolWhether this resource offers an export. Off by default: exporting is a capability a resource opts into, not something every list should carry.
reorder: Option<ReorderConfig>Rows kept in an order of their own, held in an integer column. Off by
default; reorder: true in a file orders by sort_order.
tree: Option<TreeConfig>Rows shown as a tree on their own parent column. Off by default;
tree: true in a file reads parent_id.
toolbar: Vec<ToolbarButton>Extra buttons in the toolbar, beside New and the export menu.
search: SearchConfig§per_page_options: Vec<i64>Page sizes the operator may choose from in the list setup, remembered with their column choice. Empty offers no choice.
no_records_message: Option<Text>Shown when the list has no records at all. None shows “No records yet.”
row_click: RowClickWhat clicking a row does. Default open: the row opens its record when
the list has an edit_base.
remember: boolWhether the sort, search, filters and page an operator last used come
back when they return to the list. Default true.
Implementations§
Source§impl ListConfig
impl ListConfig
Sourcepub fn new(
entity: impl Into<String>,
title: impl Into<Text>,
columns: Vec<ListColumn>,
) -> ListConfig
pub fn new( entity: impl Into<String>, title: impl Into<Text>, columns: Vec<ListColumn>, ) -> ListConfig
A list over entity titled title, showing columns.
Everything else takes the defaults below and is opted into through a builder method, so a field added later costs existing descriptors nothing.
Sourcepub fn order(self, column: impl Into<String>, dir: SortDir) -> ListConfig
pub fn order(self, column: impl Into<String>, dir: SortDir) -> ListConfig
Orders by column in dir rather than newest id first.
pub fn per_page(self, rows: i64) -> ListConfig
Sourcepub fn id_field(self, column: impl Into<String>) -> ListConfig
pub fn id_field(self, column: impl Into<String>) -> ListConfig
The primary-key column, when it is not id.
Sourcepub fn edit_base(self, base: impl Into<String>) -> ListConfig
pub fn edit_base(self, base: impl Into<String>) -> ListConfig
Links rows to {base}/{id}/edit.
Sourcepub fn creatable(self) -> ListConfig
pub fn creatable(self) -> ListConfig
Offers a New link to {edit_base}/new. Opt in, matching the read-only
default: a list over a log, or over records another screen owns, should
not invite an operator to create one.
Sourcepub fn exportable(self) -> ListConfig
pub fn exportable(self) -> ListConfig
Offers CSV and JSON exports of the current query. Opt in: a resource whose rows should not leave the panel simply never calls this, and the route is not registered for it.
pub fn filters(self, filters: Vec<ListFilter>) -> ListConfig
Sourcepub fn deletable(self) -> ListConfig
pub fn deletable(self) -> ListConfig
Lets rows be selected and deleted. Off by default: a list showing a log, or records another screen owns, has no business offering it.
Sourcepub fn tree(self, tree: TreeConfig) -> ListConfig
pub fn tree(self, tree: TreeConfig) -> ListConfig
Shows the rows as a tree on their parent column: the list opens on the top level, and a row with children expands in place.
Sourcepub fn reorder(self, column: impl Into<String>) -> ListConfig
pub fn reorder(self, column: impl Into<String>) -> ListConfig
Keeps the rows in an order of their own, held in column: the list
opens in that order with a grip and Move up / Move down on every row.
pub fn toolbar(self, buttons: Vec<ToolbarButton>) -> ListConfig
pub fn search(self, search: SearchConfig) -> ListConfig
pub fn per_page_options(self, sizes: Vec<i64>) -> ListConfig
pub fn no_records_message(self, text: impl Into<Text>) -> ListConfig
Sourcepub fn row_click(self, action: RowClick) -> ListConfig
pub fn row_click(self, action: RowClick) -> ListConfig
What clicking a row does. Default: it opens the record.
Sourcepub fn remember(self, remember: bool) -> ListConfig
pub fn remember(self, remember: bool) -> ListConfig
Whether the query an operator last used comes back when they return.
Default true.
Trait Implementations§
Source§impl Clone for ListConfig
impl Clone for ListConfig
Source§fn clone(&self) -> ListConfig
fn clone(&self) -> ListConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ListConfig
impl Debug for ListConfig
Source§impl Default for ListConfig
impl Default for ListConfig
Source§fn default() -> ListConfig
fn default() -> ListConfig
A minimal list: no columns, newest-id first, 25 to a page, read-only.
Descriptors use this as the tail of a struct literal
(..Default::default()) and set only what they mean. A field added here
later is then additive for every descriptor rather than breaking it, which
three consecutive additions made the case for.
Source§impl<'de> Deserialize<'de> for ListConfigwhere
ListConfig: Default,
impl<'de> Deserialize<'de> for ListConfigwhere
ListConfig: Default,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ListConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ListConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for ListConfig
impl Serialize for ListConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl !RefUnwindSafe for ListConfig
impl !UnwindSafe for ListConfig
impl Freeze for ListConfig
impl Send for ListConfig
impl Sync for ListConfig
impl Unpin for ListConfig
impl UnsafeUnpin for ListConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more