2022-02-15 23:52:44 -05:00
|
|
|
<div class="flex flex-col space-y-8 justify-center items-center">
|
2022-01-31 23:03:13 -05:00
|
|
|
<h1 class="title text-2xl title-primary-500">
|
2022-07-01 00:20:50 -04:00
|
|
|
<%= gettext("Catalog") %>
|
2022-01-31 23:03:13 -05:00
|
|
|
</h1>
|
|
|
|
|
2022-12-03 18:22:51 -05:00
|
|
|
<%= if @ammo_types |> Enum.empty?() and @search |> is_nil() do %>
|
2022-02-17 22:29:01 -05:00
|
|
|
<h2 class="title text-xl text-primary-600">
|
2022-11-19 15:04:56 -05:00
|
|
|
<%= gettext("No Ammo types") %>
|
2022-02-15 23:52:44 -05:00
|
|
|
<%= display_emoji("😔") %>
|
2022-02-01 00:12:09 -05:00
|
|
|
</h2>
|
2022-01-31 23:03:13 -05:00
|
|
|
|
2022-11-07 22:36:38 -05:00
|
|
|
<.link patch={Routes.ammo_type_index_path(Endpoint, :new)} class="btn btn-primary">
|
|
|
|
<%= dgettext("actions", "Add your first type!") %>
|
|
|
|
</.link>
|
2022-02-01 00:12:09 -05:00
|
|
|
<% else %>
|
2022-11-07 22:36:38 -05:00
|
|
|
<.link patch={Routes.ammo_type_index_path(Endpoint, :new)} class="btn btn-primary">
|
|
|
|
<%= dgettext("actions", "New Ammo type") %>
|
|
|
|
</.link>
|
2022-01-31 23:03:13 -05:00
|
|
|
|
2022-12-03 19:30:52 -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}
|
|
|
|
for={:search}
|
|
|
|
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 catalog")
|
|
|
|
) %>
|
|
|
|
</.form>
|
|
|
|
|
2022-11-10 20:40:21 -05:00
|
|
|
<.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-12-03 18:22:51 -05:00
|
|
|
<%= if @ammo_types |> Enum.empty?() do %>
|
|
|
|
<h2 class="title text-xl text-primary-600">
|
|
|
|
<%= gettext("No Ammo types") %>
|
|
|
|
<%= display_emoji("😔") %>
|
|
|
|
</h2>
|
|
|
|
<% else %>
|
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.Components.AmmoTypeTableComponent}
|
|
|
|
id="ammo_types_index_table"
|
|
|
|
action={@live_action}
|
|
|
|
ammo_types={@ammo_types}
|
|
|
|
current_user={@current_user}
|
|
|
|
show_used={@show_used}
|
|
|
|
>
|
|
|
|
<:actions :let={ammo_type}>
|
|
|
|
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
|
|
|
|
<.link
|
|
|
|
navigate={Routes.ammo_type_show_path(Endpoint, :show, ammo_type)}
|
|
|
|
class="text-primary-600 link"
|
2023-03-17 21:00:24 -04:00
|
|
|
aria-label={
|
|
|
|
dgettext("actions", "View %{ammo_type_name}", ammo_type_name: ammo_type.name)
|
|
|
|
}
|
2022-12-03 18:22:51 -05:00
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-eye"></i>
|
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
|
|
|
patch={Routes.ammo_type_index_path(Endpoint, :edit, ammo_type)}
|
|
|
|
class="text-primary-600 link"
|
2023-03-17 21:00:24 -04:00
|
|
|
aria-label={
|
|
|
|
dgettext("actions", "Edit %{ammo_type_name}", ammo_type_name: ammo_type.name)
|
|
|
|
}
|
2022-12-03 18:22:51 -05:00
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-edit"></i>
|
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
|
|
|
patch={Routes.ammo_type_index_path(Endpoint, :clone, ammo_type)}
|
|
|
|
class="text-primary-600 link"
|
2023-03-17 21:00:24 -04:00
|
|
|
aria-label={
|
|
|
|
dgettext("actions", "Clone %{ammo_type_name}", ammo_type_name: ammo_type.name)
|
|
|
|
}
|
2022-12-03 18:22:51 -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_type.id}
|
|
|
|
data-confirm={
|
|
|
|
dgettext(
|
|
|
|
"prompts",
|
|
|
|
"Are you sure you want to delete %{name}? This will delete all %{name} type ammo as well!",
|
|
|
|
name: ammo_type.name
|
|
|
|
)
|
|
|
|
}
|
2023-03-17 21:00:24 -04:00
|
|
|
aria-label={
|
|
|
|
dgettext("actions", "Delete %{ammo_type_name}", ammo_type_name: ammo_type.name)
|
|
|
|
}
|
2022-12-03 18:22:51 -05:00
|
|
|
>
|
|
|
|
<i class="fa-lg fas fa-trash"></i>
|
|
|
|
</.link>
|
|
|
|
</div>
|
|
|
|
</:actions>
|
|
|
|
</.live_component>
|
|
|
|
<% end %>
|
2022-02-01 00:12:09 -05:00
|
|
|
<% end %>
|
2022-01-31 23:03:13 -05:00
|
|
|
</div>
|
|
|
|
|
2023-02-04 10:28:13 -05:00
|
|
|
<.modal
|
|
|
|
:if={@live_action in [:new, :edit, :clone]}
|
|
|
|
return_to={Routes.ammo_type_index_path(Endpoint, :index)}
|
|
|
|
>
|
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.AmmoTypeLive.FormComponent}
|
|
|
|
id={@ammo_type.id || :new}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
ammo_type={@ammo_type}
|
|
|
|
return_to={Routes.ammo_type_index_path(Endpoint, :index)}
|
|
|
|
current_user={@current_user}
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</.modal>
|