diff --git a/demo/lib/demo_web/item_actions/user_soft_delete.ex b/demo/lib/demo_web/item_actions/user_soft_delete.ex index da02b6c6c..ab9938866 100644 --- a/demo/lib/demo_web/item_actions/user_soft_delete.ex +++ b/demo/lib/demo_web/item_actions/user_soft_delete.ex @@ -75,9 +75,12 @@ defmodule DemoWeb.ItemActions.UserSoftDelete do Backpex.Resource.update_all(item.posts, [set: [user_id: nil]], "updated", DemoWeb.PostLive) end) + %{live_resource: live_resource, params: params} = socket.assigns + socket |> clear_flash() |> put_flash(:info, success_message(socket.assigns, items)) + |> assign(:return_to, Router.get_path(socket, live_resource, params, :index)) rescue error -> Logger.error("An error occurred while deleting the resource: #{inspect(error)}") diff --git a/guides/actions/item-actions.md b/guides/actions/item-actions.md index dca426950..f71e6cebe 100644 --- a/guides/actions/item-actions.md +++ b/guides/actions/item-actions.md @@ -77,12 +77,13 @@ See `Backpex.ItemAction` for a list of all available callbacks. ## Placement of Item Actions -Item actions can be placed in the resource table or at the top of it. You can specify the placement of the item action by using the `only` key. +Item actions can be placed in the index view on resource table, on top of it or in the show viw. You can specify the placement of the item action by using the `only` key. -The only key must provide a list and accepts the following options +The `only` key must provide a list and accepts the following options * `:row` - display an icon for each element in the table that can trigger the Item Action for the corresponding element * `:index` - display a button at the top of the resource table, which triggers the Item Action for selected items +* `:show` - display a icon at the top of the resource view, which triggers the Item Action for the corresponding element The following example shows how to place the `show` item action on the index table rows only. diff --git a/lib/backpex/html/resource.ex b/lib/backpex/html/resource.ex index c663ed53a..f6905ce7d 100644 --- a/lib/backpex/html/resource.ex +++ b/lib/backpex/html/resource.ex @@ -643,7 +643,7 @@ defmodule Backpex.HTML.Resource do