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

131 lines
4.3 KiB
Plaintext
Raw Normal View History

2022-01-31 23:03:13 -05:00
<div class="mx-8 flex flex-col space-y-8 justify-center items-center">
<h1 class="title text-2xl title-primary-500">
2022-02-15 17:33:07 -05:00
<%= gettext("Ammo Types") %>
2022-01-31 23:03:13 -05:00
</h1>
2022-02-01 00:12:09 -05:00
<%= if @ammo_types |> Enum.empty?() do %>
<h2 class="title text-xl text-primary-500">
2022-02-09 00:39:27 -05:00
<%= gettext("No Ammo Types") %> 😔
2022-02-01 00:12:09 -05:00
</h2>
2022-01-31 23:03:13 -05:00
2022-02-09 00:39:27 -05:00
<%= live_patch(dgettext("actions", "Add your first type!"),
2022-02-01 00:12:09 -05:00
to: Routes.ammo_type_index_path(@socket, :new),
2022-02-01 01:08:18 -05:00
class: "btn btn-primary"
) %>
2022-02-01 00:12:09 -05:00
<% else %>
2022-02-09 00:39:27 -05:00
<%= live_patch(dgettext("actions", "New Ammo type"),
2022-02-01 00:12:09 -05:00
to: Routes.ammo_type_index_path(@socket, :new),
2022-02-01 01:08:18 -05:00
class: "btn btn-primary"
) %>
2022-01-31 23:03:13 -05:00
2022-02-01 00:12:09 -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-09 00:39:27 -05:00
<%= for field_name <- [
gettext("Name"),
gettext("Bullet type"),
gettext("Bullet core"),
gettext("Cartridge"),
gettext("Caliber"),
gettext("Case material"),
gettext("Grains"),
gettext("Pressure"),
gettext("Primer type"),
gettext("Rimfire"),
gettext("Tracer"),
gettext("Incendiary"),
gettext("Blank"),
gettext("Corrosive"),
gettext("Manufacturer"),
gettext("Sku")
2022-02-05 16:22:02 -05:00
] do %>
<th class="p-2">
2022-02-09 00:39:27 -05:00
<%= field_name %>
2022-02-05 16:22:02 -05:00
</th>
<% end %>
2022-01-31 23:03:13 -05:00
2022-02-01 00:12:09 -05:00
<th class="p-2"></th>
2022-01-31 23:03:13 -05:00
</tr>
2022-02-01 00:12:09 -05:00
</thead>
<tbody>
<%= for ammo_type <- @ammo_types do %>
<tr id={"ammo_type-#{ammo_type.id}"}>
2022-02-05 16:22:02 -05:00
<%= for field <- [
:name,
:bullet_type,
:bullet_core,
:cartridge,
:caliber,
:case_material,
:grains,
:pressure,
:primer_type
2022-02-05 16:22:02 -05:00
] do %>
<td class="p-2">
<%= ammo_type |> Map.get(field) %>
</td>
<% end %>
2022-02-01 00:12:09 -05:00
2022-02-05 16:22:02 -05:00
<%= 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 %>
2022-02-05 01:59:40 -05:00
2022-02-05 16:22:02 -05:00
<%= live_patch to: Routes.ammo_type_index_path(@socket, :edit, ammo_type),
2022-02-05 16:22:20 -05:00
class: "text-primary-500 link" do %>
2022-02-05 16:22:02 -05:00
<i class="fa-lg fas fa-edit"></i>
<% end %>
2022-02-05 01:59:40 -05:00
2022-02-05 16:22:02 -05:00
<%= link to: "#",
2022-02-05 16:22:20 -05:00
class: "text-primary-500 link",
phx_click: "delete",
phx_value_id: ammo_type.id,
2022-02-09 00:39:27 -05:00
data: [confirm: dgettext("prompts", "Are you sure you want to delete this ammo?")] do %>
2022-02-05 16:22:02 -05:00
<i class="fa-lg fas fa-trash"></i>
<% end %>
</div>
2022-02-01 00:12:09 -05:00
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
2022-01-31 23:03:13 -05:00
</div>
<%= if @live_action in [:new, :edit] do %>
2022-02-14 01:26:51 -05:00
<.modal return_to={Routes.ammo_type_index_path(Endpoint, :index)}>
<.live_component
module={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(Endpoint, :index)}
current_user={@current_user}
}
/>
</.modal>
2022-01-31 23:03:13 -05:00
<% end %>