2022-02-05 01:59:40 -05:00
|
|
|
<div class="mx-auto space-y-4 max-w-3xl flex flex-col justify-center items-center">
|
|
|
|
<h1 class="title text-2xl title-primary-500">
|
|
|
|
<%= @ammo_group.ammo_type.name %>
|
|
|
|
</h1>
|
|
|
|
|
|
|
|
<div class="space-y-2 flex flex-col justify-center items-center">
|
|
|
|
<span class="rounded-lg title text-lg">
|
2022-02-09 00:20:04 -05:00
|
|
|
<%= gettext("Count:") %>
|
|
|
|
<%= @ammo_group.count %>
|
2022-02-05 01:59:40 -05:00
|
|
|
</span>
|
|
|
|
|
2022-02-19 00:05:22 -05:00
|
|
|
<span class="rounded-lg title text-lg">
|
|
|
|
<%= gettext("Original count:") %>
|
2022-11-12 14:33:11 -05:00
|
|
|
<%= Ammo.get_original_count(@ammo_group) %>
|
2022-02-19 00:05:22 -05:00
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="rounded-lg title text-lg">
|
|
|
|
<%= gettext("Percentage left:") %>
|
2022-11-08 21:34:36 -05:00
|
|
|
<%= gettext("%{percentage}%", percentage: @ammo_group |> Ammo.get_percentage_remaining()) %>
|
2022-02-19 00:05:22 -05:00
|
|
|
</span>
|
|
|
|
|
2022-02-05 01:59:40 -05:00
|
|
|
<%= if @ammo_group.notes do %>
|
|
|
|
<span class="rounded-lg title text-lg">
|
2022-02-09 00:20:04 -05:00
|
|
|
<%= gettext("Notes:") %>
|
|
|
|
<%= @ammo_group.notes %>
|
2022-02-05 01:59:40 -05:00
|
|
|
</span>
|
|
|
|
<% end %>
|
|
|
|
|
2022-05-05 21:43:03 -04:00
|
|
|
<span class="rounded-lg title text-lg">
|
2022-11-19 14:52:01 -05:00
|
|
|
<%= gettext("Purchased on:") %>
|
2023-01-26 00:39:16 -05:00
|
|
|
<.date date={@ammo_group.purchased_on} />
|
2022-05-05 21:43:03 -04:00
|
|
|
</span>
|
|
|
|
|
2022-02-05 01:59:40 -05:00
|
|
|
<%= if @ammo_group.price_paid do %>
|
|
|
|
<span class="rounded-lg title text-lg">
|
2022-02-19 00:05:22 -05:00
|
|
|
<%= gettext("Original cost:") %>
|
2022-02-17 21:24:59 -05:00
|
|
|
<%= gettext("$%{amount}",
|
|
|
|
amount: @ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2)
|
|
|
|
) %>
|
2022-02-05 01:59:40 -05:00
|
|
|
</span>
|
2022-02-19 00:05:22 -05:00
|
|
|
|
|
|
|
<span class="rounded-lg title text-lg">
|
|
|
|
<%= gettext("Current value:") %>
|
|
|
|
<%= gettext("$%{amount}",
|
|
|
|
amount:
|
|
|
|
(@ammo_group.price_paid * Ammo.get_percentage_remaining(@ammo_group) / 100)
|
|
|
|
|> :erlang.float_to_binary(decimals: 2)
|
|
|
|
) %>
|
|
|
|
</span>
|
2022-02-05 01:59:40 -05:00
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
|
2022-02-17 21:19:01 -05:00
|
|
|
<div class="flex flex-col justify-center items-center">
|
2022-02-17 22:29:01 -05:00
|
|
|
<div class="flex flex-wrap justify-center items-center text-primary-600">
|
2022-11-07 22:36:38 -05:00
|
|
|
<.link
|
2022-11-09 23:47:11 -05:00
|
|
|
navigate={Routes.ammo_type_show_path(Endpoint, :show, @ammo_group.ammo_type)}
|
2022-11-07 22:36:38 -05:00
|
|
|
class="mx-4 my-2 btn btn-primary"
|
|
|
|
>
|
|
|
|
<%= dgettext("actions", "View in Catalog") %>
|
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
|
|
|
patch={Routes.ammo_group_show_path(Endpoint, :edit, @ammo_group)}
|
|
|
|
class="mx-4 my-2 text-primary-600 link"
|
2023-03-15 00:45:08 -04:00
|
|
|
aria-label={
|
|
|
|
gettext("Edit ammo group of %{ammo_group_count} bullets",
|
|
|
|
ammo_group_count: @ammo_group.count
|
|
|
|
)
|
|
|
|
}
|
2022-11-07 22:36:38 -05:00
|
|
|
>
|
2022-02-17 21:19:01 -05:00
|
|
|
<i class="fa-fw fa-lg fas fa-edit"></i>
|
2022-11-07 22:36:38 -05:00
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
|
|
|
href="#"
|
|
|
|
class="mx-4 my-2 text-primary-600 link"
|
|
|
|
phx-click="delete"
|
|
|
|
data-confirm={dgettext("prompts", "Are you sure you want to delete this ammo?")}
|
2023-03-15 00:45:08 -04:00
|
|
|
aria-label={
|
|
|
|
gettext("Delete ammo group of %{ammo_group_count} bullets",
|
|
|
|
ammo_group_count: @ammo_group.count
|
|
|
|
)
|
|
|
|
}
|
2022-11-07 22:36:38 -05:00
|
|
|
>
|
2022-02-17 21:19:01 -05:00
|
|
|
<i class="fa-fw fa-lg fas fa-trash"></i>
|
2022-11-07 22:36:38 -05:00
|
|
|
</.link>
|
2022-02-17 21:19:01 -05:00
|
|
|
</div>
|
|
|
|
|
2022-02-17 22:29:01 -05:00
|
|
|
<div class="flex flex-wrap justify-center items-center text-primary-600">
|
2022-02-17 21:19:01 -05:00
|
|
|
<button type="button" class="mx-4 my-2 btn btn-primary" phx-click="toggle_staged">
|
2022-02-17 21:24:59 -05:00
|
|
|
<%= if @ammo_group.staged,
|
2022-11-09 18:45:28 -05:00
|
|
|
do: dgettext("actions", "Unstage from range"),
|
|
|
|
else: dgettext("actions", "Stage for range") %>
|
2022-02-17 21:19:01 -05:00
|
|
|
</button>
|
2022-02-15 17:33:45 -05:00
|
|
|
|
2022-11-07 22:36:38 -05:00
|
|
|
<.link
|
|
|
|
patch={Routes.ammo_group_show_path(Endpoint, :move, @ammo_group)}
|
|
|
|
class="btn btn-primary"
|
|
|
|
>
|
|
|
|
<%= dgettext("actions", "Move containers") %>
|
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
|
|
|
patch={Routes.ammo_group_show_path(Endpoint, :add_shot_group, @ammo_group)}
|
|
|
|
class="mx-4 my-2 btn btn-primary"
|
|
|
|
>
|
|
|
|
<%= dgettext("actions", "Record shots") %>
|
|
|
|
</.link>
|
2022-02-17 21:19:01 -05:00
|
|
|
</div>
|
2022-02-05 01:59:40 -05:00
|
|
|
</div>
|
|
|
|
|
2022-02-17 21:24:59 -05:00
|
|
|
<hr class="mb-4 w-full" />
|
2022-02-05 01:59:40 -05:00
|
|
|
|
|
|
|
<div>
|
|
|
|
<%= if @ammo_group.container do %>
|
|
|
|
<h1 class="mb-4 px-4 py-2 text-center rounded-lg title text-xl">
|
2022-02-09 00:20:04 -05:00
|
|
|
<%= gettext("Stored in") %>
|
2022-02-05 01:59:40 -05:00
|
|
|
</h1>
|
|
|
|
|
|
|
|
<.container_card container={@ammo_group.container} />
|
|
|
|
<% else %>
|
2022-07-01 00:23:04 -04:00
|
|
|
<%= gettext("This ammo is not in a container") %>
|
2022-02-05 01:59:40 -05:00
|
|
|
<% end %>
|
|
|
|
</div>
|
2022-02-19 00:05:22 -05:00
|
|
|
|
|
|
|
<%= unless @ammo_group.shot_groups |> Enum.empty?() do %>
|
|
|
|
<hr class="mb-4 w-full" />
|
|
|
|
|
|
|
|
<h1 class="mb-4 px-4 py-2 text-center rounded-lg title text-xl">
|
|
|
|
<%= gettext("Rounds used") %>
|
|
|
|
</h1>
|
|
|
|
|
2022-03-04 21:57:22 -05:00
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.Components.TableComponent}
|
2022-03-04 22:27:09 -05:00
|
|
|
id="ammo_group_shot_groups_table"
|
2022-03-04 21:57:22 -05:00
|
|
|
columns={@columns}
|
|
|
|
rows={@rows}
|
|
|
|
/>
|
2022-02-19 00:05:22 -05:00
|
|
|
<% end %>
|
2022-02-05 01:59:40 -05:00
|
|
|
</div>
|
|
|
|
|
2022-02-15 18:20:12 -05:00
|
|
|
<%= case @live_action do %>
|
|
|
|
<% :edit -> %>
|
|
|
|
<.modal return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}>
|
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.AmmoGroupLive.FormComponent}
|
|
|
|
id={@ammo_group.id}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
ammo_group={@ammo_group}
|
|
|
|
return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}
|
2022-02-23 20:45:58 -05:00
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
|
|
|
<% :edit_shot_group -> %>
|
|
|
|
<.modal return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}>
|
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.RangeLive.FormComponent}
|
|
|
|
id={@shot_group.id}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
shot_group={@shot_group}
|
|
|
|
return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}
|
2022-02-15 18:20:12 -05:00
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
|
|
|
<% :add_shot_group -> %>
|
|
|
|
<.modal return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}>
|
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.Components.AddShotGroupComponent}
|
|
|
|
id={:new}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
ammo_group={@ammo_group}
|
|
|
|
return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}
|
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
|
|
|
<% :move -> %>
|
|
|
|
<.modal return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}>
|
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.Components.MoveAmmoGroupComponent}
|
|
|
|
id={@ammo_group.id}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
ammo_group={@ammo_group}
|
|
|
|
return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}
|
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
|
|
|
<% _show -> %>
|
2022-04-19 20:08:12 -04:00
|
|
|
<% end %>
|