108 lines
3.2 KiB
Plaintext
108 lines
3.2 KiB
Plaintext
<div class="flex flex-col space-y-8 justify-center items-center">
|
|
<h1 class="title text-2xl title-primary-500">
|
|
<%= gettext("Range day") %>
|
|
</h1>
|
|
|
|
<%= if @ammo_groups |> Enum.empty?() do %>
|
|
<h1 class="title text-xl text-primary-600">
|
|
<%= gettext("No ammo staged") %>
|
|
<%= display_emoji("😔") %>
|
|
</h1>
|
|
|
|
<.link navigate={Routes.ammo_group_index_path(Endpoint, :index)} class="btn btn-primary">
|
|
<%= dgettext("actions", "Why not get some ready to shoot?") %>
|
|
</.link>
|
|
<% else %>
|
|
<.link navigate={Routes.ammo_group_index_path(Endpoint, :index)} class="btn btn-primary">
|
|
<%= dgettext("actions", "Stage ammo") %>
|
|
</.link>
|
|
|
|
<%= 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?")}"}
|
|
>
|
|
<%= if ammo_group.staged,
|
|
do: dgettext("actions", "Unstage from range"),
|
|
else: dgettext("actions", "Stage for range") %>
|
|
</button>
|
|
|
|
<.link
|
|
patch={Routes.range_index_path(Endpoint, :add_shot_group, ammo_group)}
|
|
class="btn btn-primary"
|
|
>
|
|
<%= dgettext("actions", "Record shots") %>
|
|
</.link>
|
|
</.ammo_group_card>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<hr class="hr" />
|
|
|
|
<%= if @shot_groups |> Enum.empty?() do %>
|
|
<h1 class="title text-xl text-primary-600">
|
|
<%= gettext("No shots recorded") %>
|
|
<%= display_emoji("😔") %>
|
|
</h1>
|
|
<% else %>
|
|
<h1 class="title text-2xl text-primary-600">
|
|
<%= gettext("Shot log") %>
|
|
</h1>
|
|
|
|
<canvas
|
|
id="shot-log-chart"
|
|
phx-hook="ShotLogChart"
|
|
phx-update="ignore"
|
|
class="max-h-72"
|
|
data-chart-data={Jason.encode!(@chart_data)}
|
|
data-label={gettext("Rounds fired")}
|
|
data-color={random_color()}
|
|
aria-label={gettext("Rounds fired chart")}
|
|
role="img"
|
|
>
|
|
<%= dgettext("errors", "Your browser does not support the canvas element.") %>
|
|
</canvas>
|
|
|
|
<.live_component
|
|
module={CanneryWeb.Components.TableComponent}
|
|
id="shot_groups_index_table"
|
|
columns={@columns}
|
|
rows={@rows}
|
|
initial_key={:date}
|
|
initial_sort_mode={:desc}
|
|
/>
|
|
<% 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 %>
|