cannery/lib/cannery_web/live/container_live/show.ex

36 lines
864 B
Elixir
Raw Normal View History

2021-09-02 23:31:14 -04:00
defmodule CanneryWeb.ContainerLive.Show do
2022-01-22 21:40:29 -05:00
@moduledoc """
Liveview for showing and editing a Cannery.Containers.Container
"""
2021-09-02 23:31:14 -04:00
use CanneryWeb, :live_view
alias Cannery.Containers
@impl true
2021-09-02 23:31:16 -04:00
def mount(_params, session, socket) do
{:ok, socket |> assign_defaults(session)}
2021-09-02 23:31:14 -04:00
end
@impl true
def handle_params(%{"id" => id}, _, socket) do
2022-01-31 21:56:02 -05:00
socket =
socket
|> assign(
page_title: page_title(socket.assigns.live_action),
container: Containers.get_container!(id)
)
{:noreply, socket}
end
@impl true
def handle_event("delete", _, socket) do
socket.assigns.container |> Containers.delete_container!()
{:noreply, socket |> push_redirect(to: Routes.container_index_path(socket, :index))}
2021-09-02 23:31:14 -04:00
end
defp page_title(:show), do: "Show Container"
defp page_title(:edit), do: "Edit Container"
end