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

193 lines
5.7 KiB
Plaintext
Raw Normal View History

2022-11-06 23:12:17 -05:00
<div class="space-y-4 flex flex-col justify-center items-center">
2022-01-31 21:56:02 -05:00
<h1 class="title text-2xl title-primary-500">
<%= @container.name %>
</h1>
2023-02-04 10:28:13 -05:00
<span :if={@container.desc} class="rounded-lg title text-lg">
<%= gettext("Description:") %>
<%= @container.desc %>
</span>
2022-01-31 21:56:02 -05:00
<span class="rounded-lg title text-lg">
2022-02-09 00:49:47 -05:00
<%= gettext("Type:") %>
<%= @container.type %>
2022-01-31 21:56:02 -05:00
</span>
2023-02-04 10:28:13 -05:00
<span :if={@container.location} class="rounded-lg title text-lg">
<%= gettext("Location:") %>
<%= @container.location %>
</span>
2022-01-31 21:56:02 -05:00
2023-03-23 22:07:25 -04:00
<span class="rounded-lg title text-lg">
<%= gettext("Packs:") %>
2023-03-29 22:54:55 -04:00
<%= @packs_count %>
2023-03-23 22:07:25 -04:00
</span>
<span class="rounded-lg title text-lg">
<%= gettext("Rounds:") %>
<%= @round_count %>
</span>
2022-07-01 19:13:54 -04:00
2022-02-17 22:29:01 -05:00
<div class="flex space-x-4 justify-center items-center text-primary-600">
<.link
2023-04-14 23:34:11 -04:00
patch={~p"/container/edit/#{@container}"}
class="text-primary-600 link"
2023-03-17 21:00:24 -04:00
aria-label={dgettext("actions", "Edit %{container_name}", container_name: @container.name)}
>
2022-02-05 01:59:40 -05:00
<i class="fa-fw fa-lg fas fa-edit"></i>
</.link>
2022-02-05 01:59:40 -05:00
<.link
href="#"
class="text-primary-600 link"
phx-click="delete_container"
data-confirm={
dgettext("prompts", "Are you sure you want to delete %{name}?", name: @container.name)
}
2023-03-17 21:00:24 -04:00
aria-label={
dgettext("actions", "Delete %{container_name}", container_name: @container.name)
}
>
2022-02-05 01:59:40 -05:00
<i class="fa-fw fa-lg fas fa-trash"></i>
</.link>
2022-01-31 21:56:02 -05:00
</div>
2022-02-17 21:24:59 -05:00
<hr class="mb-4 hr" />
2022-02-13 21:14:48 -05:00
<%= if @container.tags |> Enum.empty?() do %>
<div class="flex flex-row justify-center items-center space-x-4">
2022-02-17 22:29:01 -05:00
<h2 class="title text-lg text-primary-600">
2022-02-15 23:52:44 -05:00
<%= gettext("No tags for this container") %>
<%= display_emoji("😔") %>
2022-02-13 21:14:48 -05:00
</h2>
2023-04-14 23:34:11 -04:00
<.link patch={~p"/container/edit_tags/#{@container}"} class="btn btn-primary">
<%= dgettext("actions", "Why not add one?") %>
</.link>
2022-02-13 21:14:48 -05:00
</div>
<% else %>
2022-02-18 22:56:46 -05:00
<div class="flex flex-wrap justify-center items-center">
2023-02-04 10:28:13 -05:00
<.simple_tag_card :for={tag <- @container.tags} tag={tag} />
2022-02-13 21:14:48 -05:00
2022-02-18 22:56:46 -05:00
<div class="mx-4 my-2">
2023-04-14 23:34:11 -04:00
<.link patch={~p"/container/edit_tags/#{@container}"} class="text-primary-600 link">
2022-02-18 22:56:46 -05:00
<i class="fa-fw fa-lg fas fa-tags"></i>
</.link>
2022-02-18 22:56:46 -05:00
</div>
</div>
2022-02-13 21:14:48 -05:00
<% end %>
2022-02-17 21:24:59 -05:00
<hr class="mb-4 hr" />
2022-01-31 21:56:02 -05:00
<div class="flex justify-center items-center space-x-4">
2023-03-23 22:07:25 -04:00
<.form
:let={f}
for={%{}}
2023-03-30 21:53:52 -04:00
as={:type}
2023-03-28 23:08:40 -04:00
phx-change="change_class"
phx-submit="change_class"
2023-03-23 22:07:25 -04:00
class="flex items-center"
>
2023-03-28 23:08:40 -04:00
<%= label(f, :class, gettext("Class"), class: "title text-primary-600 text-lg text-center") %>
2023-03-23 22:07:25 -04:00
<%= select(
f,
2023-03-28 23:08:40 -04:00
:class,
2023-03-23 22:07:25 -04:00
[
{gettext("All"), :all},
{gettext("Rifle"), :rifle},
{gettext("Shotgun"), :shotgun},
{gettext("Pistol"), :pistol}
],
class: "mx-2 my-1 min-w-md input input-primary",
2023-03-28 23:08:40 -04:00
value: @class
2023-03-23 22:07:25 -04:00
) %>
</.form>
<.toggle_button action="toggle_table" value={@view_table}>
<span class="title text-lg text-primary-600">
<%= gettext("View as table") %>
</span>
</.toggle_button>
</div>
<div class="w-full p-4">
2023-03-29 22:54:55 -04:00
<%= if @packs |> Enum.empty?() do %>
<h2 class="mx-4 title text-lg text-primary-600 text-center">
2022-07-01 00:23:04 -04:00
<%= gettext("No ammo in this container") %>
2022-02-23 20:35:18 -05:00
</h2>
2022-02-05 01:59:40 -05:00
<% else %>
<%= if @view_table do %>
<.live_component
2023-03-29 22:54:55 -04:00
module={CanneryWeb.Components.PackTableComponent}
2023-05-12 21:50:23 -04:00
id="pack-show-table"
2023-03-29 22:54:55 -04:00
packs={@packs}
current_user={@current_user}
2023-03-23 22:07:25 -04:00
show_used={false}
>
2023-03-30 21:53:52 -04:00
<:type :let={%{name: type_name} = type}>
2023-04-14 23:34:11 -04:00
<.link navigate={~p"/type/#{type}"} class="link">
2023-03-30 21:53:52 -04:00
<%= type_name %>
</.link>
2023-03-30 21:53:52 -04:00
</:type>
<:actions :let={%{count: pack_count} = pack}>
<div class="py-2 px-4 h-full space-x-4 flex justify-center items-center">
<.link
navigate={~p"/ammo/show/#{pack}"}
class="text-primary-600 link"
aria-label={
dgettext("actions", "View pack of %{pack_count} bullets",
pack_count: pack_count
)
}
>
<i class="fa-fw fa-lg fas fa-eye"></i>
</.link>
</div>
</:actions>
</.live_component>
<% else %>
2022-12-03 22:09:32 -05:00
<div class="flex flex-wrap justify-center items-stretch">
2023-03-29 22:58:07 -04:00
<.pack_card
2023-03-29 22:54:55 -04:00
:for={%{id: pack_id} = pack <- @packs}
pack={pack}
original_count={Map.fetch!(@original_counts, pack_id)}
cpr={Map.get(@cprs, pack_id)}
last_used_date={Map.get(@last_used_dates, pack_id)}
current_user={@current_user}
/>
</div>
<% end %>
2022-02-05 01:59:40 -05:00
<% end %>
2022-02-23 20:35:18 -05:00
</div>
2022-01-31 21:56:02 -05:00
</div>
2022-02-13 21:14:48 -05:00
<%= case @live_action do %>
<% :edit -> %>
2023-04-14 23:34:11 -04:00
<.modal return_to={~p"/container/#{@container}"}>
<.live_component
module={CanneryWeb.ContainerLive.FormComponent}
id={@container.id}
title={@page_title}
action={@live_action}
container={@container}
2023-04-14 23:34:11 -04:00
return_to={~p"/container/#{@container}"}
current_user={@current_user}
/>
</.modal>
<% :edit_tags -> %>
2023-04-14 23:34:11 -04:00
<.modal return_to={~p"/container/#{@container}"}>
<.live_component
module={CanneryWeb.ContainerLive.EditTagsComponent}
id={@container.id}
title={@page_title}
action={@live_action}
container={@container}
2023-04-14 23:34:11 -04:00
return_to={~p"/container/#{@container}"}
current_path={~p"/container/edit_tags/#{@container}"}
current_user={@current_user}
/>
</.modal>
<% _ -> %>
<% end %>