2022-11-06 23:08:18 -05:00
|
|
|
<div class="space-y-4 flex flex-col justify-center items-center">
|
2022-01-31 23:20:57 -05:00
|
|
|
<h1 class="title text-2xl title-primary-500">
|
|
|
|
<%= @ammo_type.name %>
|
|
|
|
</h1>
|
|
|
|
|
2022-02-05 16:22:02 -05:00
|
|
|
<%= if @ammo_type.desc do %>
|
2022-04-19 20:08:12 -04:00
|
|
|
<span class="max-w-2xl w-full px-8 py-4 rounded-lg
|
2022-02-05 16:22:02 -05:00
|
|
|
text-center title text-lg
|
2022-04-19 20:08:12 -04:00
|
|
|
border border-primary-600">
|
2022-02-05 16:22:02 -05:00
|
|
|
<%= @ammo_type.desc %>
|
|
|
|
</span>
|
|
|
|
<% end %>
|
2022-02-05 01:59:40 -05:00
|
|
|
|
2022-02-17 22:29:01 -05:00
|
|
|
<div class="flex space-x-4 justify-center items-center text-primary-600">
|
2022-02-17 22:31:37 -05:00
|
|
|
<%= live_patch to: Routes.ammo_type_show_path(Endpoint, :edit, @ammo_type),
|
2022-02-17 22:29:01 -05:00
|
|
|
class: "text-primary-600 link",
|
2022-02-16 22:39:53 -05:00
|
|
|
data: [qa: "edit"] do %>
|
2022-02-05 01:59:40 -05:00
|
|
|
<i class="fa-fw fa-lg fas fa-edit"></i>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
<%= link to: "#",
|
2022-02-17 22:29:01 -05:00
|
|
|
class: "text-primary-600 link",
|
2022-02-05 01:59:40 -05:00
|
|
|
phx_click: "delete",
|
2022-02-09 00:39:27 -05:00
|
|
|
data: [
|
|
|
|
confirm:
|
2022-07-04 21:39:28 -04:00
|
|
|
dgettext("prompts", "Are you sure you want to delete %{name}? This will delete all %{name} type ammo as well!", name: @ammo_type.name),
|
2022-02-16 22:39:53 -05:00
|
|
|
qa: "delete"
|
2022-02-09 00:39:27 -05:00
|
|
|
] do %>
|
2022-02-05 01:59:40 -05:00
|
|
|
<i class="fa-fw fa-lg fas fa-trash"></i>
|
|
|
|
<% end %>
|
2022-01-31 23:20:57 -05:00
|
|
|
</div>
|
|
|
|
|
2022-02-17 21:24:59 -05:00
|
|
|
<hr class="hr" />
|
2022-02-05 16:22:02 -05:00
|
|
|
|
2022-02-18 23:25:44 -05:00
|
|
|
<div class="grid sm:grid-cols-2 gap-4 text-center justify-center items-center">
|
|
|
|
<%= for {field_name, field, type} <- [
|
|
|
|
{gettext("Bullet type"), :bullet_type, :string},
|
|
|
|
{gettext("Bullet core"), :bullet_core, :string},
|
|
|
|
{gettext("Cartridge"), :cartridge, :string},
|
|
|
|
{gettext("Caliber"), :caliber, :string},
|
|
|
|
{gettext("Case material"), :case_material, :string},
|
|
|
|
{gettext("Jacket type"), :jacket_type, :string},
|
|
|
|
{gettext("Muzzle velocity"), :muzzle_velocity, :string},
|
|
|
|
{gettext("Powder type"), :powder_type, :string},
|
|
|
|
{gettext("Powder grains per charge"), :powder_grains_per_charge, :string},
|
|
|
|
{gettext("Grains"), :grains, :string},
|
|
|
|
{gettext("Pressure"), :pressure, :string},
|
|
|
|
{gettext("Primer type"), :primer_type, :string},
|
|
|
|
{gettext("Firing type"), :firing_type, :string},
|
|
|
|
{gettext("Tracer"), :tracer, :boolean},
|
|
|
|
{gettext("Incendiary"), :incendiary, :boolean},
|
|
|
|
{gettext("Blank"), :blank, :boolean},
|
|
|
|
{gettext("Corrosive"), :corrosive, :boolean},
|
|
|
|
{gettext("Manufacturer"), :manufacturer, :string},
|
|
|
|
{gettext("UPC"), :upc, :string}
|
2022-02-05 16:22:02 -05:00
|
|
|
] do %>
|
|
|
|
<%= if @ammo_type |> Map.get(field) do %>
|
2022-02-18 23:25:44 -05:00
|
|
|
<h3 class="title text-lg">
|
2022-02-17 21:24:59 -05:00
|
|
|
<%= field_name %>:
|
2022-02-05 16:22:02 -05:00
|
|
|
</h3>
|
|
|
|
|
2022-02-18 23:25:44 -05:00
|
|
|
<span class="text-primary-600">
|
|
|
|
<%= case type do %>
|
|
|
|
<% :boolean -> %>
|
|
|
|
<%= @ammo_type |> Map.get(field) |> humanize() %>
|
|
|
|
<% _ -> %>
|
|
|
|
<%= @ammo_type |> Map.get(field) %>
|
|
|
|
<% end %>
|
2022-02-05 16:22:02 -05:00
|
|
|
</span>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
2022-02-06 00:40:01 -05:00
|
|
|
|
2022-02-19 00:18:24 -05:00
|
|
|
<h3 class="title text-lg">
|
|
|
|
<%= gettext("Current # of rounds:") %>
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
<span class="text-primary-600">
|
|
|
|
<%= @ammo_type |> Ammo.get_round_count_for_ammo_type(@current_user) %>
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<h3 class="title text-lg">
|
|
|
|
<%= gettext("Total rounds shot:") %>
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
<span class="text-primary-600">
|
|
|
|
<%= @ammo_type |> Ammo.get_used_count_for_ammo_type(@current_user) %>
|
|
|
|
</span>
|
|
|
|
|
2022-05-05 21:43:49 -04:00
|
|
|
<h3 class="title text-lg">
|
|
|
|
<%= gettext("Added on:") %>
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
<span class="text-primary-600">
|
|
|
|
<%= @ammo_type.inserted_at |> display_datetime() %>
|
|
|
|
</span>
|
|
|
|
|
2022-02-06 00:40:01 -05:00
|
|
|
<%= if @avg_cost_per_round do %>
|
2022-02-18 23:25:44 -05:00
|
|
|
<h3 class="title text-lg">
|
2022-02-17 21:24:59 -05:00
|
|
|
<%= gettext("Average Price paid") %>:
|
2022-02-06 00:40:01 -05:00
|
|
|
</h3>
|
|
|
|
|
2022-02-18 23:25:44 -05:00
|
|
|
<span class="text-primary-600">
|
2022-02-17 21:24:59 -05:00
|
|
|
<%= gettext("$%{amount}",
|
|
|
|
amount: @avg_cost_per_round |> :erlang.float_to_binary(decimals: 2)
|
|
|
|
) %>
|
2022-02-06 00:40:01 -05:00
|
|
|
</span>
|
2022-02-18 23:25:44 -05:00
|
|
|
<% else %>
|
2022-02-23 19:41:21 -05:00
|
|
|
<h3 class="mx-8 my-4 title text-lg text-primary-600 col-span-2">
|
2022-02-18 23:25:44 -05:00
|
|
|
<%= gettext("No cost information") %>
|
|
|
|
</h3>
|
2022-02-06 00:40:01 -05:00
|
|
|
<% end %>
|
2022-02-05 16:22:02 -05:00
|
|
|
</div>
|
|
|
|
|
2022-02-17 21:24:59 -05:00
|
|
|
<hr class="hr" />
|
2022-02-05 01:59:40 -05:00
|
|
|
|
2022-11-07 00:25:34 -05:00
|
|
|
<div class="flex flex-col justify-center items-center">
|
|
|
|
<.toggle_button action="toggle_show_used" value={@show_used}>
|
|
|
|
<span class="title text-lg text-primary-600">
|
|
|
|
<%= gettext("Show used") %>
|
|
|
|
</span>
|
|
|
|
</.toggle_button>
|
|
|
|
</div>
|
|
|
|
|
2022-02-05 16:22:02 -05:00
|
|
|
<div>
|
2022-02-08 00:21:22 -05:00
|
|
|
<%= if @ammo_groups |> Enum.empty?() do %>
|
2022-02-23 19:41:21 -05:00
|
|
|
<h2 class="mx-8 my-4 title text-lg text-primary-600">
|
|
|
|
<%= gettext("No ammo for this type") %>
|
|
|
|
<%= display_emoji("😔") %>
|
|
|
|
</h2>
|
2022-02-05 01:59:40 -05:00
|
|
|
<% else %>
|
2022-02-18 23:06:32 -05:00
|
|
|
<div class="flex flex-wrap justify-center items-center">
|
|
|
|
<%= for ammo_group <- @ammo_groups do %>
|
2022-11-06 23:30:16 -05:00
|
|
|
<.ammo_group_card ammo_group={ammo_group} show_container={true} />
|
2022-02-18 23:06:32 -05:00
|
|
|
<% end %>
|
|
|
|
</div>
|
2022-02-05 01:59:40 -05:00
|
|
|
<% end %>
|
|
|
|
</div>
|
2022-01-31 23:20:57 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<%= if @live_action in [:edit] do %>
|
2022-02-14 01:26:51 -05:00
|
|
|
<.modal return_to={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)}>
|
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.AmmoTypeLive.FormComponent}
|
|
|
|
id={@ammo_type.id}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
ammo_type={@ammo_type}
|
|
|
|
return_to={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)}
|
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
2022-01-31 23:20:57 -05:00
|
|
|
<% end %>
|