pub struct ModelAdminConfig { /* private fields */ }Expand description
Configuration-based model admin implementation
Provides a simple way to configure model admin without implementing the trait.
§Examples
use reinhardt_admin::core::{ModelAdminConfig, ModelAdmin};
let admin = ModelAdminConfig::builder()
.model_name("User")
.list_display(vec!["id", "username", "email"])
.list_filter(vec!["is_active"])
.search_fields(vec!["username", "email"])
.build();
assert_eq!(admin.model_name(), "User");Implementations§
Source§impl ModelAdminConfig
impl ModelAdminConfig
Sourcepub fn new(model_name: impl Into<String>) -> Self
pub fn new(model_name: impl Into<String>) -> Self
Create a new model admin configuration
§Examples
use reinhardt_admin::core::{ModelAdminConfig, ModelAdmin};
let admin = ModelAdminConfig::new("User");
assert_eq!(admin.model_name(), "User");Sourcepub fn builder() -> ModelAdminConfigBuilder
pub fn builder() -> ModelAdminConfigBuilder
Start building a model admin configuration
§Examples
use reinhardt_admin::core::ModelAdminConfig;
let admin = ModelAdminConfig::builder()
.model_name("User")
.list_display(vec!["id", "username"])
.build();Sourcepub fn with_list_display(self, fields: Vec<impl Into<String>>) -> Self
pub fn with_list_display(self, fields: Vec<impl Into<String>>) -> Self
Set list display fields
Sourcepub fn with_list_filter(self, fields: Vec<impl Into<String>>) -> Self
pub fn with_list_filter(self, fields: Vec<impl Into<String>>) -> Self
Set list filter fields
Sourcepub fn with_search_fields(self, fields: Vec<impl Into<String>>) -> Self
pub fn with_search_fields(self, fields: Vec<impl Into<String>>) -> Self
Set search fields
Trait Implementations§
Source§impl Clone for ModelAdminConfig
impl Clone for ModelAdminConfig
Source§fn clone(&self) -> ModelAdminConfig
fn clone(&self) -> ModelAdminConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ModelAdminConfig
impl Debug for ModelAdminConfig
Source§impl ModelAdmin for ModelAdminConfig
impl ModelAdmin for ModelAdminConfig
Source§fn model_name(&self) -> &str
fn model_name(&self) -> &str
Get the model name
Source§fn table_name(&self) -> &str
fn table_name(&self) -> &str
Get the database table name Read more
Source§fn list_display(&self) -> Vec<&str>
fn list_display(&self) -> Vec<&str>
Fields to display in list view
Source§fn list_filter(&self) -> Vec<&str>
fn list_filter(&self) -> Vec<&str>
Fields that can be used for filtering
Source§fn search_fields(&self) -> Vec<&str>
fn search_fields(&self) -> Vec<&str>
Fields that can be searched
Source§fn readonly_fields(&self) -> Vec<&str>
fn readonly_fields(&self) -> Vec<&str>
Read-only fields
Source§fn list_per_page(&self) -> Option<usize>
fn list_per_page(&self) -> Option<usize>
Number of items per page (None = use site default)
Source§fn has_view_permission<'life0, 'life1, 'async_trait>(
&'life0 self,
_user: &'life1 (dyn Any + Send + Sync),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has_view_permission<'life0, 'life1, 'async_trait>(
&'life0 self,
_user: &'life1 (dyn Any + Send + Sync),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if user has permission to view this model Read more
Source§fn has_add_permission<'life0, 'life1, 'async_trait>(
&'life0 self,
_user: &'life1 (dyn Any + Send + Sync),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has_add_permission<'life0, 'life1, 'async_trait>(
&'life0 self,
_user: &'life1 (dyn Any + Send + Sync),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if user has permission to add instances Read more
Source§fn has_change_permission<'life0, 'life1, 'async_trait>(
&'life0 self,
_user: &'life1 (dyn Any + Send + Sync),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has_change_permission<'life0, 'life1, 'async_trait>(
&'life0 self,
_user: &'life1 (dyn Any + Send + Sync),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if user has permission to change instances Read more
Source§fn has_delete_permission<'life0, 'life1, 'async_trait>(
&'life0 self,
_user: &'life1 (dyn Any + Send + Sync),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has_delete_permission<'life0, 'life1, 'async_trait>(
&'life0 self,
_user: &'life1 (dyn Any + Send + Sync),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if user has permission to delete instances Read more
Auto Trait Implementations§
impl Freeze for ModelAdminConfig
impl RefUnwindSafe for ModelAdminConfig
impl Send for ModelAdminConfig
impl Sync for ModelAdminConfig
impl Unpin for ModelAdminConfig
impl UnwindSafe for ModelAdminConfig
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
Mutably borrows from an owned value. Read more
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>
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 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>
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