Group Actions
Group related custom actions under a single dropdown, either by wrapping them in action_group or by giving them the same group_name.
Quick exampleβ
cm_show page_title: :title do
action_group "Status", icon_name: "fa-regular fa-flag" do
custom_action name: "approve", route_type: "member", verb: "patch", path: ":id/approve", display_type: :button do
::Post.find(params[:id]).tap(&:approved!)
end
custom_action name: "reject", route_type: "member", verb: "patch", path: ":id/reject", display_type: :button do
::Post.find(params[:id]).tap(&:rejected!)
end
end
end
Optionsβ
action_group(name, icon_name: "fa fa-list", icon_style: nil, &block)
| Name | Type | Default | Description |
|---|---|---|---|
name | String | required | Label of the dropdown. |
icon_name | String | "fa fa-list" | Font Awesome icon of the group. |
icon_style | String | nil | Inline style for the group icon. |
Every custom_action declared inside the block joins the group and takes its icon.
Recipesβ
Group without a blockβ
Actions with the same group_name are grouped together, even when declared apart:
custom_action name: "approve", group_name: "Status", route_type: "member", verb: "patch",
path: ":id/approve", display_type: :button do
::Post.find(params[:id]).tap(&:approved!)
end