Skip to main content

EntityAdmin

Struct EntityAdmin 

Source
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: EntityPermissions

Implementations§

Source§

impl EntityAdmin

Source

pub fn new<T>(_entity: &str) -> Self

Source

pub fn label(self, label: &str) -> Self

Source

pub fn pk_field(self, pk: &str) -> Self

Source

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

Source

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.

Source

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

Source

pub fn list_display(self, fields: Vec<String>) -> Self

Source

pub fn search_fields(self, fields: Vec<String>) -> Self

Source

pub fn filter_fields(self, fields: Vec<String>) -> Self

Source

pub fn filter(self, field: Field) -> Self

Source

pub fn bulk_delete(self, enabled: bool) -> Self

Source

pub fn bulk_export(self, enabled: bool) -> Self

Source

pub fn adapter(self, adapter: Box<dyn DataAdapter>) -> Self

Source

pub fn action(self, action: CustomAction) -> Self

Source

pub fn before_save<F>(self, f: F) -> Self
where F: Fn(&mut HashMap<String, Value>) -> Result<(), AdminError> + Send + Sync + 'static,

Source

pub fn after_delete<F>(self, f: F) -> Self
where F: Fn(&Value) -> Result<(), AdminError> + Send + Sync + 'static,

Source

pub fn require_view(self, perm: &str) -> Self

Require perm to list or view this entity.

Source

pub fn require_create(self, perm: &str) -> Self

Require perm to create a new record.

Source

pub fn require_edit(self, perm: &str) -> Self

Require perm to edit an existing record.

Source

pub fn require_delete(self, perm: &str) -> Self

Require perm to delete a record.

Source

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

Source§

fn from(e: EntityAdmin) -> Self

Converts to this type from the input type.

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,