147 lines
4.3 KiB
Plaintext
147 lines
4.3 KiB
Plaintext
<div class="flex flex-col space-y-8 justify-center items-center">
|
|
<h1 class="title text-2xl title-primary-500">
|
|
<%= gettext("Catalog") %>
|
|
</h1>
|
|
|
|
<%= if @types_count == 0 do %>
|
|
<h2 class="title text-xl text-primary-600">
|
|
<%= gettext("No Types") %>
|
|
<%= display_emoji("😔") %>
|
|
</h2>
|
|
|
|
<.link patch={~p"/catalog/new"} class="btn btn-primary">
|
|
<%= dgettext("actions", "Add your first type!") %>
|
|
</.link>
|
|
<% else %>
|
|
<.link patch={~p"/catalog/new"} class="btn btn-primary">
|
|
<%= dgettext("actions", "New Type") %>
|
|
</.link>
|
|
|
|
<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-2xl">
|
|
<.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>
|
|
|
|
<.form
|
|
:let={f}
|
|
for={%{}}
|
|
as={:search}
|
|
phx-change="search"
|
|
phx-submit="search"
|
|
class="grow flex items-center"
|
|
>
|
|
<%= text_input(f, :search_term,
|
|
class: "grow input input-primary",
|
|
phx_debounce: 300,
|
|
placeholder: gettext("Search catalog"),
|
|
role: "search",
|
|
value: @search
|
|
) %>
|
|
</.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>
|
|
|
|
<%= if @types |> Enum.empty?() do %>
|
|
<h2 class="title text-xl text-primary-600">
|
|
<%= gettext("No Types") %>
|
|
<%= display_emoji("😔") %>
|
|
</h2>
|
|
<% else %>
|
|
<.live_component
|
|
module={CanneryWeb.Components.TypeTableComponent}
|
|
id="types-index-table"
|
|
action={@live_action}
|
|
types={@types}
|
|
current_user={@current_user}
|
|
show_used={@show_used}
|
|
class={@class}
|
|
>
|
|
<:actions :let={type}>
|
|
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
|
|
<.link
|
|
navigate={~p"/type/#{type}"}
|
|
class="text-primary-600 link"
|
|
aria-label={dgettext("actions", "View %{type_name}", type_name: type.name)}
|
|
>
|
|
<i class="fa-fw fa-lg fas fa-eye"></i>
|
|
</.link>
|
|
|
|
<.link
|
|
patch={~p"/catalog/edit/#{type}"}
|
|
class="text-primary-600 link"
|
|
aria-label={dgettext("actions", "Edit %{type_name}", type_name: type.name)}
|
|
>
|
|
<i class="fa-fw fa-lg fas fa-edit"></i>
|
|
</.link>
|
|
|
|
<.link
|
|
patch={~p"/catalog/clone/#{type}"}
|
|
class="text-primary-600 link"
|
|
aria-label={dgettext("actions", "Clone %{type_name}", type_name: type.name)}
|
|
>
|
|
<i class="fa-fw fa-lg fas fa-copy"></i>
|
|
</.link>
|
|
|
|
<.link
|
|
href="#"
|
|
class="text-primary-600 link"
|
|
phx-click="delete"
|
|
phx-value-id={type.id}
|
|
data-confirm={
|
|
dgettext(
|
|
"prompts",
|
|
"Are you sure you want to delete %{name}? This will delete all %{name} type ammo as well!",
|
|
name: type.name
|
|
)
|
|
}
|
|
aria-label={dgettext("actions", "Delete %{type_name}", type_name: type.name)}
|
|
>
|
|
<i class="fa-lg fas fa-trash"></i>
|
|
</.link>
|
|
</div>
|
|
</:actions>
|
|
</.live_component>
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<.modal :if={@live_action in [:new, :edit, :clone]} return_to={~p"/catalog"}>
|
|
<.live_component
|
|
module={CanneryWeb.TypeLive.FormComponent}
|
|
id={@type.id || :new}
|
|
title={@page_title}
|
|
action={@live_action}
|
|
type={@type}
|
|
return_to={~p"/catalog"}
|
|
current_user={@current_user}
|
|
}
|
|
/>
|
|
</.modal>
|