add containers show page
This commit is contained in:
parent
b14c5ce88a
commit
cc7162d267
@ -14,10 +14,20 @@ defmodule CanneryWeb.ContainerLive.Show do
|
||||
|
||||
@impl true
|
||||
def handle_params(%{"id" => id}, _, socket) do
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:page_title, page_title(socket.assigns.live_action))
|
||||
|> assign(:container, Containers.get_container!(id))}
|
||||
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))}
|
||||
end
|
||||
|
||||
defp page_title(:show), do: "Show Container"
|
||||
|
46
lib/cannery_web/live/container_live/show.html.heex
Normal file
46
lib/cannery_web/live/container_live/show.html.heex
Normal file
@ -0,0 +1,46 @@
|
||||
<div class="mx-auto space-y-4 max-w-3xl flex flex-col justify-center items-center">
|
||||
<h1 class="title text-2xl title-primary-500">
|
||||
<%= @container.name %>
|
||||
</h1>
|
||||
|
||||
<%= if @container.desc do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
Description: <%= @container.desc %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<span class="rounded-lg title text-lg">
|
||||
Type: <%= @container.type %>
|
||||
</span>
|
||||
|
||||
<%= if @container.location do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
Location: <%= @container.location %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<div class="flex space-x-4 justify-center items-center text-primary-500">
|
||||
<%= live_redirect("Back", to: Routes.container_index_path(@socket, :index), class: "link") %>
|
||||
<%= live_patch("Edit", to: Routes.container_show_path(@socket, :edit, @container), class: "link") %>
|
||||
<%= link("Delete",
|
||||
to: "#",
|
||||
class: "link",
|
||||
phx_click: "delete",
|
||||
data: [confirm: "Are you sure you want to delete #{@container.name}?"]
|
||||
) %>
|
||||
</div>
|
||||
|
||||
<hr class="mb-4 w-full">
|
||||
|
||||
<p>No ammo groups in this container</p>
|
||||
|
||||
<%= if @live_action in [:edit] do %>
|
||||
<%= live_modal(CanneryWeb.ContainerLive.FormComponent,
|
||||
id: @container.id,
|
||||
title: @page_title,
|
||||
action: @live_action,
|
||||
container: @container,
|
||||
return_to: Routes.container_show_path(@socket, :show, @container)
|
||||
) %>
|
||||
<% end %>
|
||||
</div>
|
@ -1,37 +0,0 @@
|
||||
<h1>Show Container</h1>
|
||||
|
||||
<%= if @live_action in [:edit] do %>
|
||||
<%= live_modal CanneryWeb.ContainerLive.FormComponent,
|
||||
id: @container.id,
|
||||
title: @page_title,
|
||||
action: @live_action,
|
||||
container: @container,
|
||||
return_to: Routes.container_show_path(@socket, :show, @container) %>
|
||||
<% end %>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<strong>Name:</strong>
|
||||
<%= @container.name %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Desc:</strong>
|
||||
<%= @container.desc %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Type:</strong>
|
||||
<%= @container.type %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Location:</strong>
|
||||
<%= @container.location %>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<span><%= live_patch "Edit", to: Routes.container_show_path(@socket, :edit, @container), class: "button" %></span>
|
||||
<span><%= live_redirect "Back", to: Routes.container_index_path(@socket, :index) %></span>
|
Loading…
Reference in New Issue
Block a user