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">
|
2023-03-30 21:53:52 -04:00
|
|
|
<%= @pack.type.name %>
|
2022-02-05 01:59:40 -05:00
|
|
|
</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:") %>
|
2023-03-29 22:54:55 -04:00
|
|
|
<%= @pack.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:") %>
|
2023-03-18 21:06:00 -04:00
|
|
|
<%= @original_count %>
|
2022-02-19 00:05:22 -05:00
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="rounded-lg title text-lg">
|
|
|
|
<%= gettext("Percentage left:") %>
|
2023-03-18 21:06:00 -04:00
|
|
|
<%= gettext("%{percentage}%", percentage: @percentage_remaining) %>
|
2022-02-19 00:05:22 -05:00
|
|
|
</span>
|
|
|
|
|
2023-03-29 22:54:55 -04:00
|
|
|
<%= if @pack.notes do %>
|
2022-02-05 01:59:40 -05:00
|
|
|
<span class="rounded-lg title text-lg">
|
2022-02-09 00:20:04 -05:00
|
|
|
<%= gettext("Notes:") %>
|
2023-03-29 22:54:55 -04:00
|
|
|
<%= @pack.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-03-29 22:54:55 -04:00
|
|
|
<.date id={"#{@pack.id}-purchased-on"} date={@pack.purchased_on} />
|
2022-05-05 21:43:03 -04:00
|
|
|
</span>
|
|
|
|
|
2023-03-29 22:54:55 -04:00
|
|
|
<%= if @pack.price_paid do %>
|
2022-02-05 01:59:40 -05:00
|
|
|
<span class="rounded-lg title text-lg">
|
2022-02-19 00:05:22 -05:00
|
|
|
<%= gettext("Original cost:") %>
|
2023-03-29 22:54:55 -04:00
|
|
|
<%= gettext("$%{amount}", amount: display_currency(@pack.price_paid)) %>
|
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}",
|
2023-03-29 22:54:55 -04:00
|
|
|
amount: display_currency(@pack.price_paid * @percentage_remaining / 100)
|
2022-02-19 00:05:22 -05:00
|
|
|
) %>
|
|
|
|
</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
|
2023-03-30 21:53:52 -04:00
|
|
|
navigate={Routes.type_show_path(Endpoint, :show, @pack.type)}
|
2022-11-07 22:36:38 -05:00
|
|
|
class="mx-4 my-2 btn btn-primary"
|
|
|
|
>
|
|
|
|
<%= dgettext("actions", "View in Catalog") %>
|
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
2023-03-29 22:54:55 -04:00
|
|
|
patch={Routes.pack_show_path(Endpoint, :edit, @pack)}
|
2022-11-07 22:36:38 -05:00
|
|
|
class="mx-4 my-2 text-primary-600 link"
|
2023-03-15 00:45:08 -04:00
|
|
|
aria-label={
|
2023-03-29 23:49:45 -04:00
|
|
|
dgettext("actions", "Edit pack of %{pack_count} bullets", pack_count: @pack.count)
|
2023-03-15 00:45:08 -04:00
|
|
|
}
|
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={
|
2023-03-29 23:49:45 -04:00
|
|
|
dgettext("actions", "Delete pack of %{pack_count} bullets", pack_count: @pack.count)
|
2023-03-15 00:45:08 -04:00
|
|
|
}
|
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">
|
2023-03-29 22:54:55 -04:00
|
|
|
<%= if @pack.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
|
|
|
|
2023-03-29 22:54:55 -04:00
|
|
|
<.link patch={Routes.pack_show_path(Endpoint, :move, @pack)} class="btn btn-primary">
|
2023-03-18 21:06:00 -04:00
|
|
|
<%= dgettext("actions", "Move ammo") %>
|
2022-11-07 22:36:38 -05:00
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
2023-03-30 20:43:30 -04:00
|
|
|
patch={Routes.pack_show_path(Endpoint, :add_shot_record, @pack)}
|
2022-11-07 22:36:38 -05:00
|
|
|
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>
|
2023-03-18 21:06:00 -04:00
|
|
|
<%= if @container do %>
|
2022-02-05 01:59:40 -05:00
|
|
|
<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>
|
|
|
|
|
2023-03-18 21:06:00 -04:00
|
|
|
<.container_card container={@container} current_user={@current_user} />
|
2022-02-05 01:59:40 -05:00
|
|
|
<% 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
|
|
|
|
2023-03-30 20:43:30 -04:00
|
|
|
<%= unless @shot_records |> Enum.empty?() do %>
|
2022-02-19 00:05:22 -05:00
|
|
|
<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}
|
2023-03-30 20:43:30 -04:00
|
|
|
id="pack_shot_records_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 -> %>
|
2023-03-29 22:54:55 -04:00
|
|
|
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
|
2022-02-15 18:20:12 -05:00
|
|
|
<.live_component
|
2023-03-29 22:54:55 -04:00
|
|
|
module={CanneryWeb.PackLive.FormComponent}
|
|
|
|
id={@pack.id}
|
2022-02-15 18:20:12 -05:00
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
2023-03-29 22:54:55 -04:00
|
|
|
pack={@pack}
|
|
|
|
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
|
2022-02-23 20:45:58 -05:00
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
2023-03-30 20:43:30 -04:00
|
|
|
<% :edit_shot_record -> %>
|
2023-03-29 22:54:55 -04:00
|
|
|
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
|
2022-02-23 20:45:58 -05:00
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.RangeLive.FormComponent}
|
2023-03-30 20:43:30 -04:00
|
|
|
id={@shot_record.id}
|
2022-02-23 20:45:58 -05:00
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
2023-03-30 20:43:30 -04:00
|
|
|
shot_record={@shot_record}
|
2023-03-29 22:54:55 -04:00
|
|
|
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
|
2022-02-15 18:20:12 -05:00
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
2023-03-30 20:43:30 -04:00
|
|
|
<% :add_shot_record -> %>
|
2023-03-29 22:54:55 -04:00
|
|
|
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
|
2022-02-15 18:20:12 -05:00
|
|
|
<.live_component
|
2023-03-30 20:43:30 -04:00
|
|
|
module={CanneryWeb.Components.AddShotRecordComponent}
|
2022-02-15 18:20:12 -05:00
|
|
|
id={:new}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
2023-03-29 22:54:55 -04:00
|
|
|
pack={@pack}
|
|
|
|
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
|
2022-02-15 18:20:12 -05:00
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
|
|
|
<% :move -> %>
|
2023-03-29 22:54:55 -04:00
|
|
|
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
|
2022-02-15 18:20:12 -05:00
|
|
|
<.live_component
|
2023-03-29 22:54:55 -04:00
|
|
|
module={CanneryWeb.Components.MovePackComponent}
|
|
|
|
id={@pack.id}
|
2022-02-15 18:20:12 -05:00
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
2023-03-29 22:54:55 -04:00
|
|
|
pack={@pack}
|
|
|
|
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
|
2022-02-15 18:20:12 -05:00
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
|
|
|
<% _show -> %>
|
2022-04-19 20:08:12 -04:00
|
|
|
<% end %>
|