pub struct RelationManager { /* private fields */ }Expand description
The rows of another resource, managed from a record’s own pages (Filament’s relation managers): each is a tab of the record (view and edit pages), with a list of the rows that belong to it.
has_many: rows holding the record’s id (a product’s variants or photos). They get create, edit and delete pages under the record, and the list’s bulk delete. The child’s form must have the foreign key as a field (product_id): the panel fills it with the record’s id, whatever the browser sends, and leaves it out of the form.belongs_to_many: rows joined to the record by a pivot table (the bike models a part fits). The tab lists the attached rows, with Attach (a select of the rest) and Detach.
What the user may do is asked of the managed resource
(AdminResource::allows: viewAny, create, update, delete), and
to attach or detach, of the record’s update too. The managed resource
needn’t be registered with Admin::resource.
use renox_admin::{AdminResource, Field, RelationManager};
// In the product's `impl AdminResource`:
fn relations(&self) -> Vec<RelationManager> {
vec![RelationManager::has_many("variants", "Variants", Variants, "product_id")]
}Implementations§
Source§impl RelationManager
impl RelationManager
Sourcepub fn has_many<C: AdminResource>(
key: &str,
label: &str,
child: C,
foreign_key: &str,
) -> Self
pub fn has_many<C: AdminResource>( key: &str, label: &str, child: C, foreign_key: &str, ) -> Self
Rows of child whose foreign_key column holds the record’s id,
under the address segment key (letters, digits, _ and -) and
the tab label.
§Panics
If key or foreign_key isn’t a plain name.
Sourcepub fn belongs_to_many<C: AdminResource>(
key: &str,
label: &str,
related: C,
pivot_table: &str,
parent_key: &str,
related_key: &str,
) -> Self
pub fn belongs_to_many<C: AdminResource>( key: &str, label: &str, related: C, pivot_table: &str, parent_key: &str, related_key: &str, ) -> Self
Rows of related joined to the record by pivot_table, whose
parent_key column holds the record’s id and related_key the
row’s.
§Panics
If key isn’t plain, or a table or column name has anything but
letters, digits and _.
Sourcepub fn title_column(self, column: &str) -> Self
pub fn title_column(self, column: &str) -> Self
The column that names a row in the select of
belongs_to_many’s Attach (name by
default).
§Panics
If column isn’t a plain name.
Trait Implementations§
Source§impl Clone for RelationManager
impl Clone for RelationManager
Auto Trait Implementations§
impl !RefUnwindSafe for RelationManager
impl !UnwindSafe for RelationManager
impl Freeze for RelationManager
impl Send for RelationManager
impl Sync for RelationManager
impl Unpin for RelationManager
impl UnsafeUnpin for RelationManager
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<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