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>
|
|
|
|
|
2023-03-30 21:53:52 -04:00
|
|
|
<%= if @types_count == 0 do %>
|
2022-02-17 22:29:01 -05:00
|
|
|
<h2 class="title text-xl text-primary-600">
|
2023-03-30 21:53:52 -04:00
|
|
|
<%= gettext("No 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
|
|
|
|
2023-04-14 23:34:11 -04:00
|
|
|
<.link patch={~p"/catalog/new"} class="btn btn-primary">
|
2022-11-07 22:36:38 -05:00
|
|
|
<%= dgettext("actions", "Add your first type!") %>
|
|
|
|
</.link>
|
2022-02-01 00:12:09 -05:00
|
|
|
<% else %>
|
2023-04-14 23:34:11 -04:00
|
|
|
<.link patch={~p"/catalog/new"} class="btn btn-primary">
|
2023-03-30 21:53:52 -04:00
|
|
|
<%= dgettext("actions", "New Type") %>
|
2022-11-07 22:36:38 -05:00
|
|
|
</.link>
|
2022-01-31 23:03:13 -05:00
|
|
|
|
2023-03-23 22:07:25 -04: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-2xl">
|
|
|
|
<.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-09-07 19:14:42 -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>
|
|
|
|
|
2022-12-03 19:30:52 -05:00
|
|
|
<.form
|
|
|
|
:let={f}
|
2023-03-17 21:06:08 -04:00
|
|
|
for={%{}}
|
|
|
|
as={:search}
|
2022-12-03 19:30:52 -05:00
|
|
|
phx-change="search"
|
|
|
|
phx-submit="search"
|
2023-03-23 22:07:25 -04:00
|
|
|
class="grow flex items-center"
|
2022-12-03 19:30:52 -05:00
|
|
|
>
|
|
|
|
<%= text_input(f, :search_term,
|
2023-03-23 22:07:25 -04:00
|
|
|
class: "grow input input-primary",
|
2022-12-03 19:30:52 -05:00
|
|
|
phx_debounce: 300,
|
2024-07-28 12:52:41 -04:00
|
|
|
placeholder: gettext("Search catalog"),
|
|
|
|
role: "search",
|
|
|
|
value: @search
|
2022-12-03 19:30:52 -05:00
|
|
|
) %>
|
|
|
|
</.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>
|
|
|
|
|
2023-03-30 21:53:52 -04:00
|
|
|
<%= if @types |> Enum.empty?() do %>
|
2022-12-03 18:22:51 -05:00
|
|
|
<h2 class="title text-xl text-primary-600">
|
2023-03-30 21:53:52 -04:00
|
|
|
<%= gettext("No Types") %>
|
2022-12-03 18:22:51 -05:00
|
|
|
<%= display_emoji("😔") %>
|
|
|
|
</h2>
|
|
|
|
<% else %>
|
|
|
|
<.live_component
|
2023-03-30 21:53:52 -04:00
|
|
|
module={CanneryWeb.Components.TypeTableComponent}
|
2023-05-12 21:50:23 -04:00
|
|
|
id="types-index-table"
|
2022-12-03 18:22:51 -05:00
|
|
|
action={@live_action}
|
2023-03-30 21:53:52 -04:00
|
|
|
types={@types}
|
2022-12-03 18:22:51 -05:00
|
|
|
current_user={@current_user}
|
|
|
|
show_used={@show_used}
|
2023-03-28 23:08:40 -04:00
|
|
|
class={@class}
|
2022-12-03 18:22:51 -05:00
|
|
|
>
|
2023-03-30 21:53:52 -04:00
|
|
|
<:actions :let={type}>
|
2022-12-03 18:22:51 -05:00
|
|
|
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
|
|
|
|
<.link
|
2023-04-14 23:34:11 -04:00
|
|
|
navigate={~p"/type/#{type}"}
|
2022-12-03 18:22:51 -05:00
|
|
|
class="text-primary-600 link"
|
2023-03-30 21:53:52 -04:00
|
|
|
aria-label={dgettext("actions", "View %{type_name}", type_name: type.name)}
|
2022-12-03 18:22:51 -05:00
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-eye"></i>
|
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
2023-04-14 23:34:11 -04:00
|
|
|
patch={~p"/catalog/edit/#{type}"}
|
2022-12-03 18:22:51 -05:00
|
|
|
class="text-primary-600 link"
|
2023-03-30 21:53:52 -04:00
|
|
|
aria-label={dgettext("actions", "Edit %{type_name}", type_name: type.name)}
|
2022-12-03 18:22:51 -05:00
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-edit"></i>
|
|
|
|
</.link>
|
|
|
|
|
|
|
|
<.link
|
2023-04-14 23:34:11 -04:00
|
|
|
patch={~p"/catalog/clone/#{type}"}
|
2022-12-03 18:22:51 -05:00
|
|
|
class="text-primary-600 link"
|
2023-03-30 21:53:52 -04:00
|
|
|
aria-label={dgettext("actions", "Clone %{type_name}", type_name: 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"
|
2023-03-30 21:53:52 -04:00
|
|
|
phx-value-id={type.id}
|
2022-12-03 18:22:51 -05:00
|
|
|
data-confirm={
|
|
|
|
dgettext(
|
|
|
|
"prompts",
|
|
|
|
"Are you sure you want to delete %{name}? This will delete all %{name} type ammo as well!",
|
2023-03-30 21:53:52 -04:00
|
|
|
name: type.name
|
2022-12-03 18:22:51 -05:00
|
|
|
)
|
|
|
|
}
|
2023-03-30 21:53:52 -04:00
|
|
|
aria-label={dgettext("actions", "Delete %{type_name}", type_name: 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-04-14 23:34:11 -04:00
|
|
|
<.modal :if={@live_action in [:new, :edit, :clone]} return_to={~p"/catalog"}>
|
2023-02-04 10:28:13 -05:00
|
|
|
<.live_component
|
2023-03-30 21:53:52 -04:00
|
|
|
module={CanneryWeb.TypeLive.FormComponent}
|
|
|
|
id={@type.id || :new}
|
2023-02-04 10:28:13 -05:00
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
2023-03-30 21:53:52 -04:00
|
|
|
type={@type}
|
2023-04-14 23:34:11 -04:00
|
|
|
return_to={~p"/catalog"}
|
2023-02-04 10:28:13 -05:00
|
|
|
current_user={@current_user}
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</.modal>
|