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

94 lines
3.1 KiB
Plaintext

<div class="mx-8 flex flex-col space-y-8 justify-center items-center">
<h1 class="title text-2xl title-primary-500">
<%= gettext("Listing Ammo") %>
</h1>
<%= if @ammo_groups |> Enum.empty?() do %>
<h2 class="title text-xl text-primary-500">
<%= gettext("No Ammo") %> 😔
</h2>
<%= live_patch(dgettext("actions", "Add your first box!"),
to: Routes.ammo_group_index_path(@socket, :new),
class: "btn btn-primary"
) %>
<% else %>
<%= live_patch(dgettext("actions", "New Ammo group"),
to: Routes.ammo_group_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">
<%= gettext("Count") %>
</th>
<th class="p-2">
<%= gettext("Price paid") %>
</th>
<th class="p-2">
<%= gettext("Notes") %>
</th>
<th class="p-2"></th>
</tr>
</thead>
<tbody id="ammo_groups">
<%= for ammo_group <- @ammo_groups do %>
<tr id={"ammo_group-#{ammo_group.id}"}>
<td class="p-2">
<%= ammo_group.count %>
</td>
<td class="p-2">
<%= if ammo_group.price_paid do %>
$ <%= ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2) %>
<% end %>
</td>
<td class="p-2">
<%= ammo_group.notes %>
</td>
<td class="p-2 w-full h-full space-x-2 flex justify-center items-center">
<%= live_redirect(dgettext("actions", "View"),
to: Routes.ammo_group_show_path(@socket, :show, ammo_group)
) %>
<%= live_patch to: Routes.ammo_group_index_path(@socket, :edit, ammo_group),
class: "text-primary-500 link" do %>
<i class="fa-fw fa-lg fas fa-edit"></i>
<% end %>
<%= link to: "#",
class: "text-primary-500 link",
phx_click: "delete",
phx_value_id: ammo_group.id,
data: [confirm: dgettext("prompts", "Are you sure you want to delete this ammo?")] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</div>
<%= if @live_action in [:new, :edit] do %>
<.modal return_to={Routes.ammo_group_index_path(@socket, :index)}>
<.live_component
module={CanneryWeb.AmmoGroupLive.FormComponent}
id={@ammo_group.id || :new}
title={@page_title}
action={@live_action}
ammo_group={@ammo_group}
return_to={Routes.ammo_group_index_path(@socket, :index)}
current_user={@current_user}
/>
</.modal>
<% end %>