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

193 lines
5.7 KiB
Plaintext

<div class="space-y-4 flex flex-col justify-center items-center">
<h1 class="title text-2xl title-primary-500">
<%= @container.name %>
</h1>
<span :if={@container.desc} class="rounded-lg title text-lg">
<%= gettext("Description:") %>
<%= @container.desc %>
</span>
<span class="rounded-lg title text-lg">
<%= gettext("Type:") %>
<%= @container.type %>
</span>
<span :if={@container.location} class="rounded-lg title text-lg">
<%= gettext("Location:") %>
<%= @container.location %>
</span>
<span class="rounded-lg title text-lg">
<%= gettext("Packs:") %>
<%= @packs_count %>
</span>
<span class="rounded-lg title text-lg">
<%= gettext("Rounds:") %>
<%= @round_count %>
</span>
<div class="flex space-x-4 justify-center items-center text-primary-600">
<.link
patch={~p"/container/edit/#{@container}"}
class="text-primary-600 link"
aria-label={dgettext("actions", "Edit %{container_name}", container_name: @container.name)}
>
<i class="fa-fw fa-lg fas fa-edit"></i>
</.link>
<.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)
}
aria-label={
dgettext("actions", "Delete %{container_name}", container_name: @container.name)
}
>
<i class="fa-fw fa-lg fas fa-trash"></i>
</.link>
</div>
<hr class="mb-4 hr" />
<%= if @container.tags |> Enum.empty?() do %>
<div class="flex flex-row justify-center items-center space-x-4">
<h2 class="title text-lg text-primary-600">
<%= gettext("No tags for this container") %>
<%= display_emoji("😔") %>
</h2>
<.link patch={~p"/container/edit_tags/#{@container}"} class="btn btn-primary">
<%= dgettext("actions", "Why not add one?") %>
</.link>
</div>
<% else %>
<div class="flex flex-wrap justify-center items-center">
<.simple_tag_card :for={tag <- @container.tags} tag={tag} />
<div class="mx-4 my-2">
<.link patch={~p"/container/edit_tags/#{@container}"} class="text-primary-600 link">
<i class="fa-fw fa-lg fas fa-tags"></i>
</.link>
</div>
</div>
<% end %>
<hr class="mb-4 hr" />
<div class="flex justify-center items-center space-x-4">
<.form
:let={f}
for={%{}}
as={:type}
phx-change="change_class"
phx-submit="change_class"
class="flex items-center"
>
<%= label(f, :class, gettext("Class"), class: "title text-primary-600 text-lg text-center") %>
<%= select(
f,
:class,
[
{gettext("All"), :all},
{gettext("Rifle"), :rifle},
{gettext("Shotgun"), :shotgun},
{gettext("Pistol"), :pistol}
],
class: "mx-2 my-1 min-w-md input input-primary",
value: @class
) %>
</.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">
<%= if @packs |> Enum.empty?() do %>
<h2 class="mx-4 title text-lg text-primary-600 text-center">
<%= gettext("No ammo in this container") %>
</h2>
<% else %>
<%= if @view_table do %>
<.live_component
module={CanneryWeb.Components.PackTableComponent}
id="pack-show-table"
packs={@packs}
current_user={@current_user}
show_used={false}
>
<:type :let={%{name: type_name} = type}>
<.link navigate={~p"/type/#{type}"} class="link">
<%= type_name %>
</.link>
</: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 %>
<div class="flex flex-wrap justify-center items-stretch">
<.pack_card
: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 %>
<% end %>
</div>
</div>
<%= case @live_action do %>
<% :edit -> %>
<.modal return_to={~p"/container/#{@container}"}>
<.live_component
module={CanneryWeb.ContainerLive.FormComponent}
id={@container.id}
title={@page_title}
action={@live_action}
container={@container}
return_to={~p"/container/#{@container}"}
current_user={@current_user}
/>
</.modal>
<% :edit_tags -> %>
<.modal return_to={~p"/container/#{@container}"}>
<.live_component
module={CanneryWeb.ContainerLive.EditTagsComponent}
id={@container.id}
title={@page_title}
action={@live_action}
container={@container}
return_to={~p"/container/#{@container}"}
current_path={~p"/container/edit_tags/#{@container}"}
current_user={@current_user}
/>
</.modal>
<% _ -> %>
<% end %>