Current section

Files

Jump to
backpex lib backpex item_actions edit.ex
Raw

lib/backpex/item_actions/edit.ex

defmodule Backpex.ItemActions.Edit do
@moduledoc """
Inline item action to redirect to show view.
"""
use BackpexWeb, :item_action
@impl Backpex.ItemAction
def icon(assigns) do
~H"""
<Heroicons.pencil_square class="h-5 w-5 cursor-pointer transition duration-75 hover:scale-110 hover:text-blue-600" />
"""
end
@impl Backpex.ItemAction
def label(_assigns), do: Backpex.translate("Edit")
@impl Backpex.ItemAction
def handle(socket, [item | _items], _change) do
path = Router.get_path(socket, socket.assigns.live_resource, socket.assigns.params, :edit, item)
{:noreply, Phoenix.LiveView.push_patch(socket, to: path)}
end
end