2022-02-15 23:52:44 -05:00
|
|
|
<div class="flex flex-col space-y-8 justify-center items-center">
|
2022-02-01 00:14:14 -05:00
|
|
|
<h1 class="title text-2xl title-primary-500">
|
2022-02-15 17:33:07 -05:00
|
|
|
<%= gettext("Ammo") %>
|
2022-02-01 00:14:14 -05:00
|
|
|
</h1>
|
|
|
|
|
2023-02-04 10:28:13 -05:00
|
|
|
<h2
|
|
|
|
:if={@ammo_groups |> Enum.empty?() and @search |> is_nil()}
|
|
|
|
class="title text-xl text-primary-600"
|
|
|
|
>
|
|
|
|
<%= gettext("No Ammo") %>
|
|
|
|
<%= display_emoji("😔") %>
|
|
|
|
</h2>
|
2022-02-01 00:14:14 -05:00
|
|
|
|
2022-07-04 21:41:07 -04:00
|
|
|
<%= cond do %>
|
|
|
|
<% @containers_count == 0 -> %>
|
2022-02-23 20:34:07 -05:00
|
|
|
<div class="flex justify-center items-center">
|
|
|
|
<h2 class="m-2 title text-md text-primary-600">
|
|
|
|
<%= dgettext("prompts", "You'll need to") %>
|
|
|
|
</h2>
|
|
|
|
|
2022-11-09 23:47:11 -05:00
|
|
|
<.link navigate={Routes.container_index_path(Endpoint, :new)} class="btn btn-primary">
|
2022-11-07 22:36:38 -05:00
|
|
|
<%= dgettext("actions", "add a container first") %>
|
|
|
|
</.link>
|
2022-02-23 20:34:07 -05:00
|
|
|
</div>
|
2022-07-04 21:41:07 -04:00
|
|
|
<% @ammo_types_count == 0 -> %>
|
2022-02-23 20:34:07 -05:00
|
|
|
<div class="flex justify-center items-center">
|
|
|
|
<h2 class="m-2 title text-md text-primary-600">
|
|
|
|
<%= dgettext("prompts", "You'll need to") %>
|
|
|
|
</h2>
|
|
|
|
|
2022-11-09 23:47:11 -05:00
|
|
|
<.link navigate={Routes.ammo_type_index_path(Endpoint, :new)} class="btn btn-primary">
|
2022-11-07 22:36:38 -05:00
|
|
|
<%= dgettext("actions", "add an ammo type first") %>
|
|
|
|
</.link>
|
2022-02-23 20:34:07 -05:00
|
|
|
</div>
|
2022-12-03 18:46:44 -05:00
|
|
|
<% @ammo_groups |> Enum.empty?() and @search |> is_nil() -> %>
|
2022-11-07 22:36:38 -05:00
|
|
|
<.link patch={Routes.ammo_group_index_path(Endpoint, :new)} class="btn btn-primary">
|
|
|
|
<%= dgettext("actions", "Add your first box!") %>
|
|
|
|
</.link>
|
2022-07-04 21:41:07 -04:00
|
|
|
<% true -> %>
|
2022-11-07 22:36:38 -05:00
|
|
|
<.link patch={Routes.ammo_group_index_path(Endpoint, :new)} class="btn btn-primary">
|
|
|
|
<%= dgettext("actions", "Add Ammo") %>
|
|
|
|
</.link>
|
2022-07-04 21:41:07 -04:00
|
|
|
<% end %>
|
2022-02-01 00:14:14 -05:00
|
|
|
|
2022-12-03 18:46:44 -05:00
|
|
|
<div class="w-full flex flex-col sm:flex-row justify-center items-center space-y-4 sm:space-y-0 sm:space-x-4 max-w-xl">
|
|
|
|
<.form
|
|
|
|
:let={f}
|
2023-03-17 21:06:08 -04:00
|
|
|
for={%{}}
|
|
|
|
as={:search}
|
2022-12-03 18:46:44 -05:00
|
|
|
phx-change="search"
|
|
|
|
phx-submit="search"
|
|
|
|
class="grow self-stretch flex flex-col items-stretch"
|
|
|
|
>
|
|
|
|
<%= text_input(f, :search_term,
|
|
|
|
class: "input input-primary",
|
|
|
|
value: @search,
|
|
|
|
phx_debounce: 300,
|
|
|
|
placeholder: gettext("Search ammo")
|
|
|
|
) %>
|
|
|
|
</.form>
|
|
|
|
|
|
|
|
<.toggle_button action="toggle_show_used" value={@show_used}>
|
|
|
|
<span class="title text-lg text-primary-600">
|
|
|
|
<%= gettext("Show used") %>
|
|
|
|
</span>
|
|
|
|
</.toggle_button>
|
|
|
|
</div>
|
2022-11-07 00:47:22 -05:00
|
|
|
|
2022-12-03 18:46:44 -05:00
|
|
|
<%= if @ammo_groups |> Enum.empty?() do %>
|
|
|
|
<h2 class="title text-xl text-primary-600">
|
|
|
|
<%= gettext("No Ammo") %>
|
|
|
|
<%= display_emoji("😔") %>
|
|
|
|
</h2>
|
|
|
|
<% else %>
|
2022-03-04 20:00:09 -05:00
|
|
|
<.live_component
|
2022-11-12 13:52:24 -05:00
|
|
|
module={CanneryWeb.Components.AmmoGroupTableComponent}
|
|
|
|
id="ammo-group-index-table"
|
|
|
|
ammo_groups={@ammo_groups}
|
|
|
|
current_user={@current_user}
|
|
|
|
>
|
|
|
|
<:ammo_type :let={%{name: ammo_type_name} = ammo_type}>
|
|
|
|
<.link navigate={Routes.ammo_type_show_path(Endpoint, :show, ammo_type)} class="link">
|
|
|
|
<%= ammo_type_name %>
|
|
|
|
</.link>
|
|
|
|
</:ammo_type>
|
|
|
|
<:range :let={ammo_group}>
|
|
|
|
<div class="min-w-20 py-2 px-4 h-full flex flew-wrap justify-center items-center">
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="mx-2 my-1 text-sm btn btn-primary"
|
|
|
|
phx-click="toggle_staged"
|
|
|
|
phx-value-ammo_group_id={ammo_group.id}
|
|
|
|
>
|
2023-03-17 21:00:24 -04:00
|
|
|
<%= if ammo_group.staged,
|
|
|
|
do: dgettext("actions", "Unstage"),
|
|
|
|
else: dgettext("actions", "Stage") %>
|
2022-11-12 13:52:24 -05:00
|
|
|
</button>
|
|
|
|
|
|
|
|
<.link
|
|
|
|
patch={Routes.ammo_group_index_path(Endpoint, :add_shot_group, ammo_group)}
|
|
|
|
class="mx-2 my-1 text-sm btn btn-primary"
|
|
|
|
>
|
|
|
|
<%= dgettext("actions", "Record shots") %>
|
|
|
|
</.link>
|
|
|
|
</div>
|
|
|
|
</:range>
|
2023-03-18 21:06:00 -04:00
|
|
|
<:container :let={{ammo_group, %{name: container_name} = container}}>
|
2022-11-12 13:52:24 -05:00
|
|
|
<div class="min-w-20 py-2 px-4 h-full flex flew-wrap justify-center items-center">
|
|
|
|
<.link
|
|
|
|
navigate={Routes.container_show_path(Endpoint, :show, container)}
|
|
|
|
class="mx-2 my-1 link"
|
|
|
|
>
|
|
|
|
<%= container_name %>
|
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
|
|
|
patch={Routes.ammo_group_index_path(Endpoint, :move, ammo_group)}
|
|
|
|
class="mx-2 my-1 text-sm btn btn-primary"
|
|
|
|
>
|
2023-03-18 21:06:00 -04:00
|
|
|
<%= dgettext("actions", "Move ammo") %>
|
2022-11-12 13:52:24 -05:00
|
|
|
</.link>
|
|
|
|
</div>
|
|
|
|
</:container>
|
2023-03-18 21:06:00 -04:00
|
|
|
<:actions :let={%{count: ammo_group_count} = ammo_group}>
|
2022-11-12 13:52:24 -05:00
|
|
|
<div class="py-2 px-4 h-full space-x-4 flex justify-center items-center">
|
|
|
|
<.link
|
|
|
|
navigate={Routes.ammo_group_show_path(Endpoint, :show, ammo_group)}
|
|
|
|
class="text-primary-600 link"
|
2023-03-15 00:45:08 -04:00
|
|
|
aria-label={
|
2023-03-18 21:06:00 -04:00
|
|
|
dgettext("actions", "View ammo group of %{ammo_group_count} bullets",
|
|
|
|
ammo_group_count: ammo_group_count
|
2023-03-15 00:45:08 -04:00
|
|
|
)
|
|
|
|
}
|
2022-11-12 13:52:24 -05:00
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-eye"></i>
|
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
|
|
|
patch={Routes.ammo_group_index_path(Endpoint, :edit, ammo_group)}
|
|
|
|
class="text-primary-600 link"
|
2023-03-15 00:45:08 -04:00
|
|
|
aria-label={
|
2023-03-18 21:06:00 -04:00
|
|
|
dgettext("actions", "Edit ammo group of %{ammo_group_count} bullets",
|
|
|
|
ammo_group_count: ammo_group_count
|
2023-03-15 00:45:08 -04:00
|
|
|
)
|
|
|
|
}
|
2022-11-12 13:52:24 -05:00
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-edit"></i>
|
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
|
|
|
patch={Routes.ammo_group_index_path(Endpoint, :clone, ammo_group)}
|
|
|
|
class="text-primary-600 link"
|
2023-03-15 00:45:08 -04:00
|
|
|
aria-label={
|
2023-03-18 21:06:00 -04:00
|
|
|
dgettext("actions", "Clone ammo group of %{ammo_group_count} bullets",
|
|
|
|
ammo_group_count: ammo_group_count
|
2023-03-15 00:45:08 -04:00
|
|
|
)
|
|
|
|
}
|
2022-11-12 13:52:24 -05:00
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-copy"></i>
|
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
|
|
|
href="#"
|
|
|
|
class="text-primary-600 link"
|
|
|
|
phx-click="delete"
|
|
|
|
phx-value-id={ammo_group.id}
|
|
|
|
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-18 21:06:00 -04:00
|
|
|
dgettext("actions", "Delete ammo group of %{ammo_group_count} bullets",
|
|
|
|
ammo_group_count: ammo_group_count
|
2023-03-15 00:45:08 -04:00
|
|
|
)
|
|
|
|
}
|
2022-11-12 13:52:24 -05:00
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-trash"></i>
|
|
|
|
</.link>
|
|
|
|
</div>
|
|
|
|
</:actions>
|
|
|
|
</.live_component>
|
2022-02-01 00:14:14 -05:00
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
|
2023-03-18 21:06:00 -04:00
|
|
|
<%= case @live_action do %>
|
|
|
|
<% create when create in [:new, :edit, :clone] -> %>
|
2022-02-15 18:20:12 -05:00
|
|
|
<.modal return_to={Routes.ammo_group_index_path(Endpoint, :index)}>
|
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.AmmoGroupLive.FormComponent}
|
|
|
|
id={@ammo_group.id || :new}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
ammo_group={@ammo_group}
|
|
|
|
return_to={Routes.ammo_group_index_path(Endpoint, :index)}
|
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
2023-03-18 21:06:00 -04:00
|
|
|
<% :add_shot_group -> %>
|
2022-02-15 18:20:12 -05:00
|
|
|
<.modal return_to={Routes.ammo_group_index_path(Endpoint, :index)}>
|
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.Components.AddShotGroupComponent}
|
|
|
|
id={:new}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
ammo_group={@ammo_group}
|
|
|
|
return_to={Routes.ammo_group_index_path(Endpoint, :index)}
|
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
2023-03-18 21:06:00 -04:00
|
|
|
<% :move -> %>
|
2022-02-15 18:20:12 -05:00
|
|
|
<.modal return_to={Routes.ammo_group_index_path(Endpoint, :index)}>
|
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.Components.MoveAmmoGroupComponent}
|
|
|
|
id={@ammo_group.id}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
ammo_group={@ammo_group}
|
|
|
|
return_to={Routes.ammo_group_index_path(Endpoint, :index)}
|
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|
2023-03-18 21:06:00 -04:00
|
|
|
<% _ -> %>
|
2022-03-04 20:00:09 -05:00
|
|
|
<% end %>
|