cannery/lib/cannery_web/live/pack_live/show.html.heex

182 lines
5.5 KiB
Plaintext
Raw Normal View History

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>
<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>
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">
<%= 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">
<%= 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>
<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)
) %>
</span>
2022-02-05 01:59:40 -05:00
<% end %>
</div>
<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">
<.link
2023-03-30 21:53:52 -04:00
navigate={Routes.type_show_path(Endpoint, :show, @pack.type)}
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)}
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
}
>
<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?")}
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
}
>
<i class="fa-fw fa-lg fas fa-trash"></i>
</.link>
</div>
2022-02-17 22:29:01 -05:00
<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">
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") %>
</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">
<%= dgettext("actions", "Move ammo") %>
</.link>
<.link
2023-03-30 20:43:30 -04:00
patch={Routes.pack_show_path(Endpoint, :add_shot_record, @pack)}
class="mx-4 my-2 btn btn-primary"
>
<%= dgettext("actions", "Record shots") %>
</.link>
</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 @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>
<.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>
2023-03-30 20:43:30 -04:00
<%= 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}
2023-03-30 20:43:30 -04:00
id="pack_shot_records_table"
columns={@columns}
rows={@rows}
/>
<% end %>
2022-02-05 01:59:40 -05:00
</div>
<%= case @live_action do %>
<% :edit -> %>
2023-03-29 22:54:55 -04:00
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
<.live_component
2023-03-29 22:54:55 -04:00
module={CanneryWeb.PackLive.FormComponent}
id={@pack.id}
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)}
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)}>
<.live_component
module={CanneryWeb.RangeLive.FormComponent}
2023-03-30 20:43:30 -04:00
id={@shot_record.id}
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)}
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)}>
<.live_component
2023-03-30 20:43:30 -04:00
module={CanneryWeb.Components.AddShotRecordComponent}
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)}
current_user={@current_user}
/>
</.modal>
<% :move -> %>
2023-03-29 22:54:55 -04:00
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
<.live_component
2023-03-29 22:54:55 -04:00
module={CanneryWeb.Components.MovePackComponent}
id={@pack.id}
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)}
current_user={@current_user}
/>
</.modal>
<% _show -> %>
2022-04-19 20:08:12 -04:00
<% end %>