pub struct RuntimeResource {Show 19 fields
pub slug: String,
pub title: String,
pub singular: String,
pub per_page: i64,
pub fields: Vec<FieldDef>,
pub columns: Vec<ColumnDef>,
pub data: Arc<dyn RuntimeData>,
pub navigation_label: Option<String>,
pub navigation_group: Option<String>,
pub navigation_sort: Option<i32>,
pub navigation_parent_item: Option<String>,
pub navigation_icon: Option<String>,
pub conditions: FieldConditions,
pub form_layout: FormLayout,
pub tabs: Vec<Tab>,
pub default_active_tab: Option<String>,
pub column_badges: ColumnBadges,
pub tab_counts_follow_search: bool,
pub hide_empty_tabs: bool,
}Expand description
A resource defined by data. Build it with new and the
field and column methods, then add it to the panel
with register_runtime.
Fields§
§slug: StringURL segment: "books" serves the resource at /admin/books. Lowercase letters,
digits, - and _ only.
title: StringHeading and navigation label: "Books".
singular: StringThe name of one record, for headings such as “New Book”.
per_page: i64Rows per page on the list view. The default is 20, as for a static resource.
fields: Vec<FieldDef>Form fields, in display order.
columns: Vec<ColumnDef>Table columns, in display order. Each column’s key is a field name.
data: Arc<dyn RuntimeData>Where the rows live.
The label of the navigation entry, as Filament’s $navigationLabel. None, the
default, is the title.
The navigation group the resource is listed under, as Filament’s $navigationGroup.
See IgniteResource::NAVIGATION_GROUP.
The resource’s place in the navigation, as Filament’s $navigationSort: lower first.
See IgniteResource::NAVIGATION_SORT.
The navigation entry the resource is listed under, as Filament’s
$navigationParentItem: the parent’s label or slug. See
IgniteResource::NAVIGATION_PARENT_ITEM.
The name of the navigation entry’s icon, such as post, as Filament’s
$navigationIcon. See IgniteResource::NAVIGATION_ICON.
conditions: FieldConditionsThe conditions that show or hide the form’s fields, and the live fields, as
Filament’s visible(), hidden() and live(). See FieldConditions.
form_layout: FormLayoutThe layout of the create and edit forms, as Filament’s layout components. See
FormLayout. The default has none: the form renders as one card of fields.
tabs: Vec<Tab>The tabs of the list page, in display order, as Filament’s getTabs(). See
IgniteResource::tabs. The default is none.
default_active_tab: Option<String>The key of the tab shown when the list has no tab parameter, as Filament’s
getDefaultActiveTab(). None, the default, is the first tab.
column_badges: ColumnBadgesThe list columns shown as coloured badges, as Filament’s badge() and color(). See
ColumnBadges. The default is none.
tab_counts_follow_search: boolWhether each tab’s count is for the current search. The default is false: a tab
counts all its rows. See
IgniteResource::tab_counts_follow_search.
hide_empty_tabs: boolWhether a tab whose count is 0 is left out, except the default tab and the tab shown.
The default is true. See
IgniteResource::hide_empty_tabs.
Implementations§
Source§impl RuntimeResource
impl RuntimeResource
Sourcepub fn new(
slug: impl Into<String>,
title: impl Into<String>,
singular: impl Into<String>,
data: impl RuntimeData,
) -> Self
pub fn new( slug: impl Into<String>, title: impl Into<String>, singular: impl Into<String>, data: impl RuntimeData, ) -> Self
A resource at slug with no fields or columns yet, whose rows come from data.
Sets the label of the navigation entry, as Filament’s navigationLabel.
Lists the resource under the navigation group group, as Filament’s navigationGroup.
Sets the resource’s place in the navigation, as Filament’s navigationSort: lower first.
Lists the resource under the navigation entry parent (its label or slug), as
Filament’s navigationParentItem. See
IgniteResource::NAVIGATION_PARENT_ITEM.
Sets the name of the navigation entry’s icon, as Filament’s navigationIcon: a name
such as "post" or a custom post type’s own, which the admin theme maps to its icon.
See IgniteResource::NAVIGATION_ICON.
Sourcepub fn visible(
self,
field: impl Into<String>,
rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static,
) -> Self
pub fn visible( self, field: impl Into<String>, rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static, ) -> Self
Shows the field field only when rule holds, as Filament’s ->visible(). See
FieldConditions::visible.
Hides the field field when rule holds, as Filament’s ->hidden(). See
FieldConditions::hidden.
Sourcepub fn visible_on(
self,
field: impl Into<String>,
operations: &[Operation],
) -> Self
pub fn visible_on( self, field: impl Into<String>, operations: &[Operation], ) -> Self
Shows the field field only on the forms of operations, as Filament’s
->visibleOn().
Hides the field field on the forms of operations, as Filament’s ->hiddenOn().
Sourcepub fn live(self, field: impl Into<String>) -> Self
pub fn live(self, field: impl Into<String>) -> Self
Makes the field field live, as Filament’s ->live(): a change to it in the browser
shows the form’s fields again for the new value. See FieldConditions::live.
Sourcepub fn slug_from(
self,
field: impl Into<String>,
source: impl Into<String>,
) -> Self
pub fn slug_from( self, field: impl Into<String>, source: impl Into<String>, ) -> Self
Fills the field field with the slug of the field source until the user edits it, as
Filament’s slug pattern. See FieldConditions::slug_from.
Sourcepub fn slug_locked_when(
self,
field: impl Into<String>,
rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static,
) -> Self
pub fn slug_locked_when( self, field: impl Into<String>, rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static, ) -> Self
Stops the slug field field from following its source on the edit form of a record
with a stored slug, when rule holds, such as once the record is published. See
FieldConditions::slug_locked_when.
Sourcepub fn form_layout(self, layout: FormLayout) -> Self
pub fn form_layout(self, layout: FormLayout) -> Self
Sets the layout of the create and edit forms: columns, sections and groups, as
Filament’s layout components. See FormLayout.
Sourcepub fn tab(self, tab: Tab) -> Self
pub fn tab(self, tab: Tab) -> Self
Adds a tab to the list page after the others, as a Tab in Filament’s getTabs().
The RuntimeData list is given the active tab’s conditions in
ListQuery::filter: apply them with ListFilter::apply
or ListFilter::matches.
Sourcepub fn default_active_tab(self, key: impl Into<String>) -> Self
pub fn default_active_tab(self, key: impl Into<String>) -> Self
Sets the tab shown when the list has no tab parameter, by its key, as Filament’s
getDefaultActiveTab(). Without it, the first tab is shown.
Sourcepub fn tab_counts_follow_search(self, follow: bool) -> Self
pub fn tab_counts_follow_search(self, follow: bool) -> Self
Whether each tab’s count is for the current search. The default, false, counts all
of a tab’s rows. See
IgniteResource::tab_counts_follow_search.
Sourcepub fn hide_empty_tabs(self, hide: bool) -> Self
pub fn hide_empty_tabs(self, hide: bool) -> Self
Whether a tab whose count is 0 is left out, except the default tab and the tab shown.
The default is true; false renders every tab. See
IgniteResource::hide_empty_tabs.
Sourcepub fn badge(self, column: impl Into<String>) -> Self
pub fn badge(self, column: impl Into<String>) -> Self
Shows the column column as a badge in the primary colour, as Filament’s ->badge().
See ColumnBadges::badge.
Sourcepub fn badge_color(
self,
column: impl Into<String>,
color: impl Fn(&str) -> BadgeColor + Send + Sync + 'static,
) -> Self
pub fn badge_color( self, column: impl Into<String>, color: impl Fn(&str) -> BadgeColor + Send + Sync + 'static, ) -> Self
Shows the column column as a badge whose colour color picks from the cell’s state,
as Filament’s ->badge()->color(fn (string $state) => ...). See
ColumnBadges::badge_color.
Sourcepub fn badge_inside(
self,
column: impl Into<String>,
target: impl Into<String>,
) -> Self
pub fn badge_inside( self, column: impl Into<String>, target: impl Into<String>, ) -> Self
Shows the badge of the column column inside the cell of the column target, instead
of in a column of its own. See ColumnBadges::badge_inside.
Sourcepub fn badge_on_tabs<S: Into<String>>(
self,
column: impl Into<String>,
tabs: impl IntoIterator<Item = S>,
) -> Self
pub fn badge_on_tabs<S: Into<String>>( self, column: impl Into<String>, tabs: impl IntoIterator<Item = S>, ) -> Self
Shows the badge of the column column only on the list’s tabs tabs, by key. See
ColumnBadges::badge_on_tabs.
Trait Implementations§
Source§impl Clone for RuntimeResource
impl Clone for RuntimeResource
Auto Trait Implementations§
impl !RefUnwindSafe for RuntimeResource
impl !UnwindSafe for RuntimeResource
impl Forget for RuntimeResource
impl Freeze for RuntimeResource
impl Move for RuntimeResource
impl Send for RuntimeResource
impl Sync for RuntimeResource
impl Unpin for RuntimeResource
impl UnsafeUnpin for RuntimeResource
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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