pub struct EntityAdmin {Show 17 fields
pub entity_name: String,
pub label: String,
pub icon: String,
pub group: Option<String>,
pub pk_field: String,
pub fields: Vec<Field>,
pub list_display: Vec<String>,
pub search_fields: Vec<String>,
pub filter_fields: Vec<String>,
pub filters: Vec<Field>,
pub actions: Vec<CustomAction>,
pub bulk_delete: bool,
pub bulk_export: bool,
pub adapter: Option<Box<dyn DataAdapter>>,
pub before_save: Option<Box<dyn Fn(&mut HashMap<String, Value>) -> Result<(), AdminError> + Send + Sync>>,
pub after_delete: Option<Box<dyn Fn(&Value) -> Result<(), AdminError> + Send + Sync>>,
pub permissions: EntityPermissions,
/* private fields */
}Fields§
§entity_name: String§label: String§icon: String§group: Option<String>§pk_field: String§fields: Vec<Field>§list_display: Vec<String>§search_fields: Vec<String>§filter_fields: Vec<String>§filters: Vec<Field>§actions: Vec<CustomAction>§bulk_delete: bool§bulk_export: bool§adapter: Option<Box<dyn DataAdapter>>§before_save: Option<Box<dyn Fn(&mut HashMap<String, Value>) -> Result<(), AdminError> + Send + Sync>>§after_delete: Option<Box<dyn Fn(&Value) -> Result<(), AdminError> + Send + Sync>>§permissions: EntityPermissionsImplementations§
Source§impl EntityAdmin
impl EntityAdmin
pub fn new<T>(_entity: &str) -> Self
pub fn label(self, label: &str) -> Self
pub fn pk_field(self, pk: &str) -> Self
Sourcepub fn icon(self, icon: &str) -> Self
pub fn icon(self, icon: &str) -> Self
Set the Font Awesome icon class for this entity in the sidebar and dashboard.
Defaults to "fa-solid fa-layer-group".
Sourcepub fn group(self, group: &str) -> Self
pub fn group(self, group: &str) -> Self
Assign this entity to a named sidebar group. Entities sharing the same group label are collapsed under a single expandable section.
pub fn field(self, field: Field) -> Self
pub fn list_display(self, fields: Vec<String>) -> Self
pub fn search_fields(self, fields: Vec<String>) -> Self
pub fn filter_fields(self, fields: Vec<String>) -> Self
pub fn filter(self, field: Field) -> Self
pub fn bulk_delete(self, enabled: bool) -> Self
pub fn bulk_export(self, enabled: bool) -> Self
pub fn adapter(self, adapter: Box<dyn DataAdapter>) -> Self
pub fn action(self, action: CustomAction) -> Self
pub fn before_save<F>(self, f: F) -> Self
pub fn after_delete<F>(self, f: F) -> Self
Sourcepub fn require_view(self, perm: &str) -> Self
pub fn require_view(self, perm: &str) -> Self
Require perm to list or view this entity.
Sourcepub fn require_create(self, perm: &str) -> Self
pub fn require_create(self, perm: &str) -> Self
Require perm to create a new record.
Sourcepub fn require_edit(self, perm: &str) -> Self
pub fn require_edit(self, perm: &str) -> Self
Require perm to edit an existing record.
Sourcepub fn require_delete(self, perm: &str) -> Self
pub fn require_delete(self, perm: &str) -> Self
Require perm to delete a record.
Sourcepub fn require_role(self, role: &str) -> Self
pub fn require_role(self, role: &str) -> Self
Shortcut: require role for all four actions (view, create, edit, delete).
Trait Implementations§
Source§impl From<EntityAdmin> for AdminEntry
impl From<EntityAdmin> for AdminEntry
Source§fn from(e: EntityAdmin) -> Self
fn from(e: EntityAdmin) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for EntityAdmin
impl !RefUnwindSafe for EntityAdmin
impl Send for EntityAdmin
impl Sync for EntityAdmin
impl Unpin for EntityAdmin
impl UnsafeUnpin for EntityAdmin
impl !UnwindSafe for EntityAdmin
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