forked from shibao/cannery
150 lines
4.9 KiB
Plaintext
150 lines
4.9 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>
|
|
|
|
<%= 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?")}"}
|
|
>
|
|
<%= if ammo_group.staged,
|
|
do: gettext("Unstage from range"),
|
|
else: gettext("Stage for range") %>
|
|
</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 %>
|
|
|
|
<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>
|
|
|
|
<div class="w-full overflow-x-auto border border-gray-600 rounded-lg shadow-lg bg-black">
|
|
<table class="min-w-full table-auto text-center bg-white">
|
|
<thead class="border-b border-primary-600">
|
|
<tr>
|
|
<th class="p-2">
|
|
<%= gettext("Ammo") %>
|
|
</th>
|
|
<th class="p-2">
|
|
<%= gettext("Rounds shot") %>
|
|
</th>
|
|
<th class="p-2">
|
|
<%= gettext("Notes") %>
|
|
</th>
|
|
<th class="p-2">
|
|
<%= gettext("Date") %>
|
|
</th>
|
|
|
|
<th class="p-2"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="shot_groups">
|
|
<%= for shot_group <- @shot_groups do %>
|
|
<tr id={"shot_group-#{shot_group.id}"}>
|
|
<td class="p-2">
|
|
<%= live_patch(shot_group.ammo_group.ammo_type.name,
|
|
to: Routes.ammo_group_show_path(Endpoint, :show, shot_group.ammo_group),
|
|
class: "link"
|
|
) %>
|
|
</td>
|
|
<td class="p-2">
|
|
<%= shot_group.count %>
|
|
</td>
|
|
<td class="p-2">
|
|
<%= shot_group.notes %>
|
|
</td>
|
|
<td class="p-2">
|
|
<%= shot_group.date |> display_date() %>
|
|
</td>
|
|
|
|
<td class="p-2 w-full h-full space-x-2 flex justify-center items-center">
|
|
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
|
|
<%= live_patch to: Routes.range_index_path(Endpoint, :edit, shot_group),
|
|
class: "text-primary-600 link",
|
|
data: [qa: "edit-#{shot_group.id}"] do %>
|
|
<i class="fa-fw fa-lg fas fa-edit"></i>
|
|
<% end %>
|
|
|
|
<%= link to: "#",
|
|
class: "text-primary-600 link",
|
|
phx_click: "delete",
|
|
phx_value_id: shot_group.id,
|
|
data: [
|
|
confirm: dgettext("prompts", "Are you sure you want to delete this shot record?"),
|
|
qa: "delete-#{shot_group.id}"
|
|
] do %>
|
|
<i class="fa-fw fa-lg fas fa-trash"></i>
|
|
<% end %>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<% 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 %>
|