cannery/lib/cannery_web/live/ammo_type_live/index.html.heex

96 lines
2.8 KiB
Plaintext

<div class="mx-8 flex flex-col space-y-8 justify-center items-center">
<h1 class="title text-2xl title-primary-500">
Listing Ammo Types
</h1>
<%= if @ammo_types |> Enum.empty?() do %>
<h2 class="title text-xl text-primary-500">
No Ammo Types 😔
</h2>
<%= live_patch("Add your first type!",
to: Routes.ammo_type_index_path(@socket, :new),
class: "btn btn-primary"
) %>
<% else %>
<%= live_patch("New Ammo type",
to: Routes.ammo_type_index_path(@socket, :new),
class: "btn btn-primary"
) %>
<div class="w-full overflow-x-auto border border-gray-600 rounded-lg shadow-lg bg-black">
<table class="min-w-full table-auto text-center bg-white">
<thead class="border-b border-primary-600">
<tr>
<th class="p-2">
Name
</th>
<th class="p-2">
Case material
</th>
<th class="p-2">
Bullet type
</th>
<th class="p-2">
Grain
</th>
<th class="p-2">
Manufacturer
</th>
<th class="p-2"></th>
</tr>
</thead>
<tbody>
<%= for ammo_type <- @ammo_types do %>
<tr id={"ammo_type-#{ammo_type.id}"}>
<td class="p-2">
<%= ammo_type.name %>
</td>
<td class="p-2">
<%= ammo_type.case_material %>
</td>
<td class="p-2">
<%= ammo_type.bullet_type %>
</td>
<td class="p-2">
<%= ammo_type.grain %>
</td>
<td class="p-2">
<%= ammo_type.manufacturer %>
</td>
<td class="p-2 w-full h-full space-y-2 flex flex-col justify-center items-center">
<span>
<%= live_redirect("Show", to: Routes.ammo_type_show_path(@socket, :show, ammo_type)) %>
</span>
<span>
<%= live_patch("Edit", to: Routes.ammo_type_index_path(@socket, :edit, ammo_type)) %>
</span>
<span>
<%= link("Delete",
to: "#",
phx_click: "delete",
phx_value_id: ammo_type.id,
data: [confirm: "Are you sure?"]
) %>
</span>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</div>
<%= if @live_action in [:new, :edit] do %>
<%= live_modal(CanneryWeb.AmmoTypeLive.FormComponent,
id: @ammo_type.id || :new,
title: @page_title,
action: @live_action,
ammo_type: @ammo_type,
return_to: Routes.ammo_type_index_path(@socket, :index)
) %>
<% end %>