cannery/lib/cannery_web/live/range_live/index.html.heex

92 lines
2.7 KiB
Plaintext
Raw Normal View History

2022-02-15 23:52:44 -05:00
<div class="flex flex-col space-y-8 justify-center items-center">
2022-02-15 17:33:45 -05:00
<h1 class="title text-2xl title-primary-500">
<%= gettext("Range day") %>
</h1>
<%= if @ammo_groups |> Enum.empty?() do %>
2022-02-17 22:29:01 -05:00
<h1 class="title text-xl text-primary-600">
2022-02-15 23:52:44 -05:00
<%= gettext("No ammo staged") %>
<%= display_emoji("😔") %>
2022-02-15 17:33:45 -05:00
</h1>
<%= live_patch(dgettext("actions", "Why not get some ready to shoot?"),
to: Routes.ammo_group_index_path(Endpoint, :index),
class: "btn btn-primary"
) %>
<% else %>
<%= live_patch(dgettext("actions", "Stage ammo"),
to: Routes.ammo_group_index_path(Endpoint, :index),
class: "btn btn-primary"
) %>
<%= for ammo_group <- @ammo_groups do %>
<.ammo_group_card ammo_group={ammo_group}>
<button
type="button"
class="btn btn-primary"
phx-click="toggle_staged"
phx-value-ammo_group_id={ammo_group.id}
data-confirm={"#{dgettext("prompts", "Are you sure you want to unstage this ammo?")}"}
>
2022-02-17 21:24:59 -05:00
<%= if ammo_group.staged,
do: gettext("Unstage from range"),
else: gettext("Stage for range") %>
2022-02-15 17:33:45 -05:00
</button>
<%= live_patch(dgettext("actions", "Record shots"),
to: Routes.range_index_path(Endpoint, :add_shot_group, ammo_group),
class: "btn btn-primary"
) %>
</.ammo_group_card>
<% end %>
<% end %>
2022-02-17 21:24:59 -05:00
<hr class="hr" />
2022-02-15 17:33:45 -05:00
<%= if @shot_groups |> Enum.empty?() do %>
2022-02-17 22:29:01 -05:00
<h1 class="title text-xl text-primary-600">
2022-02-15 23:52:44 -05:00
<%= gettext("No shots recorded") %>
<%= display_emoji("😔") %>
2022-02-15 17:33:45 -05:00
</h1>
<% else %>
2022-02-17 22:29:01 -05:00
<h1 class="title text-2xl text-primary-600">
<%= gettext("Shot log") %>
</h1>
<.live_component
module={CanneryWeb.Components.TableComponent}
id="shot_groups_table"
columns={@columns}
rows={@rows}
/>
2022-02-15 17:33:45 -05:00
<% end %>
</div>
<%= if @live_action in [:edit] do %>
<.modal return_to={Routes.range_index_path(Endpoint, :index)}>
<.live_component
module={CanneryWeb.RangeLive.FormComponent}
id={@shot_group.id}
title={@page_title}
action={@live_action}
shot_group={@shot_group}
return_to={Routes.range_index_path(Endpoint, :index)}
current_user={@current_user}
/>
</.modal>
<% end %>
<%= if @live_action in [:add_shot_group] do %>
<.modal return_to={Routes.range_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.range_index_path(Endpoint, :index)}
current_user={@current_user}
/>
</.modal>
<% end %>