Skip to main content

RuntimeResource

Struct RuntimeResource 

Source
pub struct RuntimeResource {
Show 17 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,
}
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: String

URL segment: "books" serves the resource at /admin/books. Lowercase letters, digits, - and _ only.

§title: String

Heading and navigation label: "Books".

§singular: String

The name of one record, for headings such as “New Book”.

§per_page: i64

Rows 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.

§navigation_label: Option<String>

The label of the navigation entry, as Filament’s $navigationLabel. None, the default, is the title.

§navigation_group: Option<String>

The navigation group the resource is listed under, as Filament’s $navigationGroup. See IgniteResource::NAVIGATION_GROUP.

§navigation_sort: Option<i32>

The resource’s place in the navigation, as Filament’s $navigationSort: lower first. See IgniteResource::NAVIGATION_SORT.

§navigation_parent_item: Option<String>

The navigation entry the resource is listed under, as Filament’s $navigationParentItem: the parent’s label or slug. See IgniteResource::NAVIGATION_PARENT_ITEM.

§navigation_icon: Option<String>

The name of the navigation entry’s icon, such as post, as Filament’s $navigationIcon. See IgniteResource::NAVIGATION_ICON.

§conditions: FieldConditions

The conditions that show or hide the form’s fields, and the live fields, as Filament’s visible(), hidden() and live(). See FieldConditions.

§form_layout: FormLayout

The 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: ColumnBadges

The list columns shown as coloured badges, as Filament’s badge() and color(). See ColumnBadges. The default is none.

Implementations§

Source§

impl RuntimeResource

Source

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.

Source

pub fn field(self, field: FieldDef) -> Self

Adds a form field after the others.

Source

pub fn column(self, column: ColumnDef) -> Self

Adds a list column after the others.

Source

pub fn per_page(self, per_page: i64) -> Self

Sets the rows per page of the list view.

Source

pub fn navigation_label(self, label: impl Into<String>) -> Self

Sets the label of the navigation entry, as Filament’s navigationLabel.

Source

pub fn navigation_group(self, group: impl Into<String>) -> Self

Lists the resource under the navigation group group, as Filament’s navigationGroup.

Source

pub fn navigation_sort(self, sort: i32) -> Self

Sets the resource’s place in the navigation, as Filament’s navigationSort: lower first.

Source

pub fn navigation_parent_item(self, parent: impl Into<String>) -> Self

Lists the resource under the navigation entry parent (its label or slug), as Filament’s navigationParentItem. See IgniteResource::NAVIGATION_PARENT_ITEM.

Source

pub fn navigation_icon(self, name: impl Into<String>) -> Self

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.

Source

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.

Source

pub fn hidden( self, field: impl Into<String>, rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static, ) -> Self

Hides the field field when rule holds, as Filament’s ->hidden(). See FieldConditions::hidden.

Source

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().

Source

pub fn hidden_on( self, field: impl Into<String>, operations: &[Operation], ) -> Self

Hides the field field on the forms of operations, as Filament’s ->hiddenOn().

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for RuntimeResource

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
Source§

impl Debug for RuntimeResource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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
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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

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

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