pub struct AdminAction<M> { /* private fields */ }Expand description
An action of a resource’s list (Filament’s bulk actions): a button over
the selected rows that runs run with their records and shows the
toast it returns. With row, each row’s menu has it too.
use renox_admin::AdminAction;
let deactivate = AdminAction::new("deactivate", "Deactivate", |products: Vec<Product>, cx| async move {
let ids: Vec<i64> = products.iter().map(|p| p.id).collect();
let n = Product::query().where_in("id", ids).update(&cx.state.db, &[("active", &false)]).await?;
Ok(Toast::success(format!("{n} products deactivated.")))
})
.confirm("Deactivate the selected products?")
.row();Every record must pass AdminResource::allows for the action’s
ability (update by default), or nothing runs (403).
Implementations§
Source§impl<M: Send + 'static> AdminAction<M>
impl<M: Send + 'static> AdminAction<M>
Trait Implementations§
Source§impl<M> Clone for AdminAction<M>
impl<M> Clone for AdminAction<M>
Auto Trait Implementations§
impl<M> !RefUnwindSafe for AdminAction<M>
impl<M> !UnwindSafe for AdminAction<M>
impl<M> Freeze for AdminAction<M>
impl<M> Send for AdminAction<M>
impl<M> Sync for AdminAction<M>
impl<M> Unpin for AdminAction<M>
impl<M> UnsafeUnpin for AdminAction<M>
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
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> ⓘ
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