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>
|
|
|
|
|
|
|
|
<%= if @ammo_groups |> Enum.empty?() do %>
|
2022-02-17 22:29:01 -05:00
|
|
|
<h2 class="title text-xl text-primary-600">
|
2022-02-15 23:52:44 -05:00
|
|
|
<%= gettext("No Ammo") %>
|
|
|
|
<%= display_emoji("😔") %>
|
2022-02-01 00:14:14 -05:00
|
|
|
</h2>
|
2022-07-04 21:41:07 -04:00
|
|
|
<% end %>
|
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>
|
|
|
|
|
|
|
|
<%= live_patch(dgettext("actions", "add a container first"),
|
|
|
|
to: Routes.container_index_path(Endpoint, :new),
|
|
|
|
class: "btn btn-primary"
|
|
|
|
) %>
|
|
|
|
</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-07-04 21:41:07 -04:00
|
|
|
<%= live_patch(dgettext("actions", "add an ammo type first"),
|
|
|
|
to: Routes.ammo_type_index_path(Endpoint, :new),
|
2022-02-23 20:34:07 -05:00
|
|
|
class: "btn btn-primary"
|
|
|
|
) %>
|
|
|
|
</div>
|
2022-07-04 21:41:07 -04:00
|
|
|
<% @ammo_groups |> Enum.empty?() -> %>
|
|
|
|
<%= live_patch(dgettext("actions", "Add your first box!"),
|
|
|
|
to: Routes.ammo_group_index_path(Endpoint, :new),
|
|
|
|
class: "btn btn-primary"
|
|
|
|
) %>
|
|
|
|
<% true -> %>
|
2022-07-01 00:23:04 -04:00
|
|
|
<%= live_patch(dgettext("actions", "Add Ammo"),
|
2022-02-23 20:34:07 -05:00
|
|
|
to: Routes.ammo_group_index_path(Endpoint, :new),
|
|
|
|
class: "btn btn-primary"
|
|
|
|
) %>
|
2022-07-04 21:41:07 -04:00
|
|
|
<% end %>
|
2022-02-01 00:14:14 -05:00
|
|
|
|
2022-07-04 21:41:07 -04:00
|
|
|
<%= unless @ammo_groups |> Enum.empty?() do %>
|
2022-11-07 00:47:22 -05:00
|
|
|
<div class="flex flex-col justify-center items-center">
|
|
|
|
<.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-03-04 20:00:09 -05:00
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.Components.TableComponent}
|
2022-03-04 22:27:09 -05:00
|
|
|
id="ammo_groups_index_table"
|
2022-03-04 20:00:09 -05:00
|
|
|
action={@live_action}
|
|
|
|
columns={@columns}
|
|
|
|
rows={@rows}
|
|
|
|
/>
|
2022-02-01 00:14:14 -05:00
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
|
2022-02-15 18:20:12 -05:00
|
|
|
<%= cond do %>
|
|
|
|
<% @live_action in [:new, :edit] -> %>
|
|
|
|
<.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>
|
|
|
|
<% @live_action == :add_shot_group -> %>
|
|
|
|
<.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>
|
|
|
|
<% @live_action == :move -> %>
|
|
|
|
<.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>
|
2022-03-04 22:27:09 -05:00
|
|
|
<% true -> %>
|
|
|
|
<%= nil %>
|
2022-03-04 20:00:09 -05:00
|
|
|
<% end %>
|