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

124 lines
3.9 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>
<%= for field <- [
:name,
:bullet_type,
:bullet_core,
:cartridge,
:caliber,
:case_material,
:grains,
:pressure,
:rimfire,
:tracer,
:incendiary,
:blank,
:corrosive,
:manufacturer,
:sku
] do %>
<th class="p-2">
<%= field |> humanize() %>
</th>
<% end %>
<th class="p-2"></th>
</tr>
</thead>
<tbody>
<%= for ammo_type <- @ammo_types do %>
<tr id={"ammo_type-#{ammo_type.id}"}>
<%= for field <- [
:name,
:bullet_type,
:bullet_core,
:cartridge,
:caliber,
:case_material,
:grains,
:pressure
] do %>
<td class="p-2">
<%= ammo_type |> Map.get(field) %>
</td>
<% end %>
<%= for field <- [
:rimfire,
:tracer,
:incendiary,
:blank,
:corrosive
] do %>
<td class="p-2">
<%= ammo_type |> Map.get(field) |> humanize() %>
</td>
<% end %>
<%= for field <- [:manufacturer, :sku] do %>
<td class="p-2">
<%= ammo_type |> Map.get(field) %>
</td>
<% end %>
<td class="p-2">
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
<%= live_redirect to: Routes.ammo_type_show_path(@socket, :show, ammo_type),
class: "text-primary-500 link" do %>
<i class="fa-lg fas fa-eye"></i>
<% end %>
<%= live_patch to: Routes.ammo_type_index_path(@socket, :edit, ammo_type),
class: "text-primary-500 link" do %>
<i class="fa-lg fas fa-edit"></i>
<% end %>
<%= link to: "#",
class: "text-primary-500 link",
phx_click: "delete",
phx_value_id: ammo_type.id,
data: [confirm: "Are you sure you want to delete this ammo?"] do %>
<i class="fa-lg fas fa-trash"></i>
<% end %>
</div>
</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 %>