182 lines
5.5 KiB
Plaintext
182 lines
5.5 KiB
Plaintext
<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">
|
|
<%= @pack.ammo_type.name %>
|
|
</h1>
|
|
|
|
<div class="space-y-2 flex flex-col justify-center items-center">
|
|
<span class="rounded-lg title text-lg">
|
|
<%= gettext("Count:") %>
|
|
<%= @pack.count %>
|
|
</span>
|
|
|
|
<span class="rounded-lg title text-lg">
|
|
<%= gettext("Original count:") %>
|
|
<%= @original_count %>
|
|
</span>
|
|
|
|
<span class="rounded-lg title text-lg">
|
|
<%= gettext("Percentage left:") %>
|
|
<%= gettext("%{percentage}%", percentage: @percentage_remaining) %>
|
|
</span>
|
|
|
|
<%= if @pack.notes do %>
|
|
<span class="rounded-lg title text-lg">
|
|
<%= gettext("Notes:") %>
|
|
<%= @pack.notes %>
|
|
</span>
|
|
<% end %>
|
|
|
|
<span class="rounded-lg title text-lg">
|
|
<%= gettext("Purchased on:") %>
|
|
<.date id={"#{@pack.id}-purchased-on"} date={@pack.purchased_on} />
|
|
</span>
|
|
|
|
<%= if @pack.price_paid do %>
|
|
<span class="rounded-lg title text-lg">
|
|
<%= gettext("Original cost:") %>
|
|
<%= gettext("$%{amount}", amount: display_currency(@pack.price_paid)) %>
|
|
</span>
|
|
|
|
<span class="rounded-lg title text-lg">
|
|
<%= gettext("Current value:") %>
|
|
<%= gettext("$%{amount}",
|
|
amount: display_currency(@pack.price_paid * @percentage_remaining / 100)
|
|
) %>
|
|
</span>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="flex flex-col justify-center items-center">
|
|
<div class="flex flex-wrap justify-center items-center text-primary-600">
|
|
<.link
|
|
navigate={Routes.ammo_type_show_path(Endpoint, :show, @pack.ammo_type)}
|
|
class="mx-4 my-2 btn btn-primary"
|
|
>
|
|
<%= dgettext("actions", "View in Catalog") %>
|
|
</.link>
|
|
|
|
<.link
|
|
patch={Routes.pack_show_path(Endpoint, :edit, @pack)}
|
|
class="mx-4 my-2 text-primary-600 link"
|
|
aria-label={
|
|
dgettext("actions", "Edit pack of %{pack_count} bullets", pack_count: @pack.count)
|
|
}
|
|
>
|
|
<i class="fa-fw fa-lg fas fa-edit"></i>
|
|
</.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?")}
|
|
aria-label={
|
|
dgettext("actions", "Delete pack of %{pack_count} bullets", pack_count: @pack.count)
|
|
}
|
|
>
|
|
<i class="fa-fw fa-lg fas fa-trash"></i>
|
|
</.link>
|
|
</div>
|
|
|
|
<div class="flex flex-wrap justify-center items-center text-primary-600">
|
|
<button type="button" class="mx-4 my-2 btn btn-primary" phx-click="toggle_staged">
|
|
<%= if @pack.staged,
|
|
do: dgettext("actions", "Unstage from range"),
|
|
else: dgettext("actions", "Stage for range") %>
|
|
</button>
|
|
|
|
<.link patch={Routes.pack_show_path(Endpoint, :move, @pack)} class="btn btn-primary">
|
|
<%= dgettext("actions", "Move ammo") %>
|
|
</.link>
|
|
|
|
<.link
|
|
patch={Routes.pack_show_path(Endpoint, :add_shot_record, @pack)}
|
|
class="mx-4 my-2 btn btn-primary"
|
|
>
|
|
<%= dgettext("actions", "Record shots") %>
|
|
</.link>
|
|
</div>
|
|
</div>
|
|
|
|
<hr class="mb-4 w-full" />
|
|
|
|
<div>
|
|
<%= if @container do %>
|
|
<h1 class="mb-4 px-4 py-2 text-center rounded-lg title text-xl">
|
|
<%= gettext("Stored in") %>
|
|
</h1>
|
|
|
|
<.container_card container={@container} current_user={@current_user} />
|
|
<% else %>
|
|
<%= gettext("This ammo is not in a container") %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<%= unless @shot_records |> 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>
|
|
|
|
<.live_component
|
|
module={CanneryWeb.Components.TableComponent}
|
|
id="pack_shot_records_table"
|
|
columns={@columns}
|
|
rows={@rows}
|
|
/>
|
|
<% end %>
|
|
</div>
|
|
|
|
<%= case @live_action do %>
|
|
<% :edit -> %>
|
|
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
|
|
<.live_component
|
|
module={CanneryWeb.PackLive.FormComponent}
|
|
id={@pack.id}
|
|
title={@page_title}
|
|
action={@live_action}
|
|
pack={@pack}
|
|
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
|
|
current_user={@current_user}
|
|
/>
|
|
</.modal>
|
|
<% :edit_shot_record -> %>
|
|
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
|
|
<.live_component
|
|
module={CanneryWeb.RangeLive.FormComponent}
|
|
id={@shot_record.id}
|
|
title={@page_title}
|
|
action={@live_action}
|
|
shot_record={@shot_record}
|
|
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
|
|
current_user={@current_user}
|
|
/>
|
|
</.modal>
|
|
<% :add_shot_record -> %>
|
|
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
|
|
<.live_component
|
|
module={CanneryWeb.Components.AddShotRecordComponent}
|
|
id={:new}
|
|
title={@page_title}
|
|
action={@live_action}
|
|
pack={@pack}
|
|
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
|
|
current_user={@current_user}
|
|
/>
|
|
</.modal>
|
|
<% :move -> %>
|
|
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
|
|
<.live_component
|
|
module={CanneryWeb.Components.MovePackComponent}
|
|
id={@pack.id}
|
|
title={@page_title}
|
|
action={@live_action}
|
|
pack={@pack}
|
|
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
|
|
current_user={@current_user}
|
|
/>
|
|
</.modal>
|
|
<% _show -> %>
|
|
<% end %>
|