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

84 lines
2.5 KiB
Plaintext
Raw Normal View History

2022-02-01 00:14:14 -05:00
<div class="mx-8 flex flex-col space-y-8 justify-center items-center">
<h1 class="title text-2xl title-primary-500">
Listing Ammo
</h1>
<%= if @ammo_groups |> Enum.empty?() do %>
<h2 class="title text-xl text-primary-500">
No Ammo 😔
</h2>
2022-02-01 01:08:18 -05:00
<%= live_patch("Add your first box!",
2022-02-01 00:14:14 -05:00
to: Routes.ammo_group_index_path(@socket, :new),
2022-02-01 01:08:18 -05:00
class: "btn btn-primary"
) %>
2022-02-01 00:14:14 -05:00
<% else %>
2022-02-01 01:08:18 -05:00
<%= live_patch("New Ammo group",
2022-02-01 00:14:14 -05:00
to: Routes.ammo_group_index_path(@socket, :new),
2022-02-01 01:08:18 -05:00
class: "btn btn-primary"
) %>
2022-02-01 00:14:14 -05:00
<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>
2022-02-01 01:08:18 -05:00
<th class="p-2">
Count
</th>
<th class="p-2">
Price paid
</th>
<th class="p-2">
Notes
</th>
2022-02-01 00:14:14 -05:00
<th class="p-2"></th>
</tr>
</thead>
<tbody id="ammo_groups">
<%= for ammo_group <- @ammo_groups do %>
<tr id={ammo_group-"#{ammo_group.id}"}>
2022-02-01 01:08:18 -05:00
<td class="p-2">
<%= ammo_group.count %>
</td>
<td class="p-2">
<%= ammo_group.price_paid %>
</td>
<td class="p-2">
<%= ammo_group.notes %>
</td>
2022-02-01 00:14:14 -05:00
<td class="p-2 w-full h-full space-y-2 flex flex-col justify-center items-center">
2022-02-01 01:08:18 -05:00
<span>
<%= live_redirect("Show", to: Routes.ammo_group_show_path(@socket, :show, ammo_group)) %>
</span>
<span>
<%= live_patch("Edit", to: Routes.ammo_group_index_path(@socket, :edit, ammo_group)) %>
</span>
<span>
<%= link("Delete",
to: "#",
phx_click: "delete",
phx_value_id: ammo_group.id,
data: [confirm: "Are you sure?"]
) %>
</span>
2022-02-01 00:14:14 -05:00
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</div>
<%= if @live_action in [:new, :edit] do %>
2022-02-01 01:08:18 -05:00
<%= live_modal(CanneryWeb.AmmoGroupLive.FormComponent,
2022-02-01 00:14:14 -05:00
id: @ammo_group.id || :new,
title: @page_title,
action: @live_action,
ammo_group: @ammo_group,
2022-02-01 01:08:18 -05:00
return_to: Routes.ammo_group_index_path(@socket, :index)
) %>
2022-02-01 00:14:14 -05:00
<% end %>