pub struct RowAction { /* private fields */ }Expand description
One action on each row of a resource’s list, as Filament’s Action::make($name) in
recordActions(). See the module documentation.
Implementations§
Source§impl RowAction
impl RowAction
Sourcepub fn make(name: impl Into<String>) -> Self
pub fn make(name: impl Into<String>) -> Self
An action named name, as Filament’s Action::make('restore'). The name is the last
segment of the action’s address, so it should be a slug such as delete_permanently.
Its label defaults to the name with _ and - as spaces and a capital first letter:
“Delete permanently”.
Sourcepub fn url(self, template: impl Into<String>) -> Self
pub fn url(self, template: impl Into<String>) -> Self
Makes the action a link to template, as Filament’s url(). Each {key} in it is
replaced by the record’s value for key, URL-encoded, such as
"/blog/{slug}?preview=1" or "/admin/posts/{id}/revisions"; a key the record does not
have is replaced by nothing. A link needs no authorize: the page it
opens checks access, as Filament says of url().
Sourcepub fn action<F>(self, handler: F) -> Selfwhere
F: for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Row) -> RuntimeFuture<'a, ActionResult> + Send + Sync + 'static,
pub fn action<F>(self, handler: F) -> Selfwhere
F: for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Row) -> RuntimeFuture<'a, ActionResult> + Send + Sync + 'static,
Makes the action a POST that runs handler, as Filament’s action(). The handler is
given the database, the signed-in user, the record’s id and the record, and answers
Ok(Ok(())) when done, Ok(Err(message)) to refuse with a message, or Err(error) for
a database error (a server error). Write it as
|db, user, id, record| Box::pin(async move { ... }).
Sourcepub fn requires_confirmation(self) -> Self
pub fn requires_confirmation(self) -> Self
Asks the user before the action runs, as Filament’s requiresConfirmation(), with
Filament’s default text, “Are you sure you would like to do this?”.
Sourcepub fn modal_description(self, text: impl Into<String>) -> Self
pub fn modal_description(self, text: impl Into<String>) -> Self
The question the confirmation asks, as Filament’s modalDescription(). It also turns
the confirmation on.
Sourcepub fn visible(
self,
rule: impl Fn(&Row) -> bool + Send + Sync + 'static,
) -> Self
pub fn visible( self, rule: impl Fn(&Row) -> bool + Send + Sync + 'static, ) -> Self
Shows the action only on the rows for which rule holds, as Filament’s visible()
with a $record closure. The panel also refuses to run it on another record. Several
rules must all hold.
Hides the action on the rows for which rule holds, as Filament’s hidden().
Sourcepub fn visible_when(self, filter: ListFilter) -> Self
pub fn visible_when(self, filter: ListFilter) -> Self
Shows the action only on the rows that meet filter, such as
ListFilter::new().where_eq("status", "trash"): visible for a rule
that is data, as a runtime resource loads it.
Sourcepub fn color(self, color: BadgeColor) -> Self
pub fn color(self, color: BadgeColor) -> Self
The button’s colour, as Filament’s color(). Danger renders the panel’s danger
button; the others render its plain button, with the class ig-action-<color> for a
theme. The default is none.
The ability the action needs, as Filament’s authorize('update') or
authorize('delete'). The default is ActionAbility::Update.
Sourcepub fn success_notification_title(self, title: impl Into<String>) -> Self
pub fn success_notification_title(self, title: impl Into<String>) -> Self
The message shown after the action ran, as Filament’s successNotificationTitle().
The default is none: the list shows again without a message.
Sourcepub fn url_for(&self, record: &Row) -> Option<String>
pub fn url_for(&self, record: &Row) -> Option<String>
The link of the action for record, when it is a link.
Sourcepub fn confirmation(&self) -> Option<&str>
pub fn confirmation(&self) -> Option<&str>
The confirmation’s text, when the action asks first.
Sourcepub fn is_visible(&self, record: &Row) -> bool
pub fn is_visible(&self, record: &Row) -> bool
Whether the action shows on record: every visibility rule holds.
Sourcepub fn get_color(&self) -> Option<BadgeColor>
pub fn get_color(&self) -> Option<BadgeColor>
The button’s colour, if set.
Sourcepub fn ability(&self) -> ActionAbility
pub fn ability(&self) -> ActionAbility
The ability the action needs.
Sourcepub fn success_message(&self) -> Option<&str>
pub fn success_message(&self) -> Option<&str>
The message shown after the action ran, if set.
Sourcepub async fn run(
&self,
db: &Database,
user: &ActingUser,
id: i64,
record: &Row,
) -> Result<ActionResult, Error>
pub async fn run( &self, db: &Database, user: &ActingUser, id: i64, record: &Row, ) -> Result<ActionResult, Error>
Runs the handler on the record id. An action without a handler (a link) answers
Ok(Err(..)); the panel does not call it then.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RowAction
impl !UnwindSafe for RowAction
impl Forget for RowAction
impl Freeze for RowAction
impl Move for RowAction
impl Send for RowAction
impl Sync for RowAction
impl Unpin for RowAction
impl UnsafeUnpin for RowAction
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
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> ⓘ
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