Skip to content

Commit

Permalink
feature: action name as proc (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob authored Feb 28, 2024
1 parent 6dd39bf commit 5d532e4
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions docs/3.0/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,29 +374,15 @@ class Avo::Actions::TogglePublished < Avo::BaseAction
end
```

### Customize the message
### Callable options

You may update the `self.message` class attribute to customize the message if there are no fields present.

#### Callable message

<VersionReq version="2.21" />

Since version `2.21` you can pass a block to `self.message` where you have access to a bunch of variables.
Both `name` and `message` allow a block. Within this block, you gain access to all attributes of [`Avo::ExecutionContext`](execution-context) along with the `record` (if on show view), `resource`, `arguments` and `view`.
### Customize the name

```ruby
class Avo::Actions::ReleaseFish < Avo::BaseAction
self.message = -> {
# you have access to:
# - params
# - current_user
# - context
# - view_context
# - request
# - resource
# - record
"Are you sure you want to release the #{record.name}?"
}
self.name = -> { "Release #{record.name}?" }
self.message = -> { "Are you sure you want to release the #{record.name}?" }
end
```

Expand Down

0 comments on commit 5d532e4

Please sign in to comment.