add adding shots to ammo group index and show page

This commit is contained in:
2022-02-17 21:19:01 -05:00
parent af3d76de1c
commit 67dc265f67
6 changed files with 81 additions and 58 deletions

View File

@ -17,6 +17,14 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
{:noreply, apply_action(socket, live_action, params)}
end
defp apply_action(%{assigns: %{current_user: current_user}} = socket, :add_shot_group, %{
"id" => id
}) do
socket
|> assign(:page_title, gettext("Record shots"))
|> assign(:ammo_group, Ammo.get_ammo_group!(id, current_user))
end
defp apply_action(%{assigns: %{current_user: current_user}} = socket, :move, %{"id" => id}) do
socket
|> assign(:page_title, gettext("Move Ammo group"))

View File

@ -36,7 +36,7 @@
<%= gettext("Notes") %>
</th>
<th class="p-2">
<%= gettext("Staged for Range") %>
<%= gettext("Range") %>
</th>
<th class="p-2">
<%= gettext("Container") %>
@ -70,14 +70,21 @@
</td>
<td class="p-2">
<button
type="button"
class="btn btn-primary"
phx-click="toggle_staged"
phx-value-ammo_group_id={ammo_group.id}
>
<%= if ammo_group.staged, do: gettext("Unstage"), else: gettext("Stage") %>
</button>
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
<button
type="button"
class="btn btn-primary"
phx-click="toggle_staged"
phx-value-ammo_group_id={ammo_group.id}
>
<%= if ammo_group.staged, do: gettext("Unstage"), else: gettext("Stage") %>
</button>
<%= live_patch(dgettext("actions", "Record shots"),
to: Routes.ammo_group_index_path(Endpoint, :add_shot_group, ammo_group),
class: "btn btn-primary"
) %>
</div>
</td>
<td class="p-2">

View File

@ -24,38 +24,47 @@
<% end %>
</div>
<div class="flex flex-wrap justify-center items-center text-primary-500">
<%= live_patch(dgettext("actions", "Ammo Details"),
to: Routes.ammo_type_show_path(Endpoint, :show, @ammo_group.ammo_type),
class: "mx-4 my-2 btn btn-primary",
data: [qa: "details"]
) %>
<div class="flex flex-col justify-center items-center">
<div class="flex flex-wrap justify-center items-center text-primary-500">
<%= live_patch(dgettext("actions", "Ammo Details"),
to: Routes.ammo_type_show_path(Endpoint, :show, @ammo_group.ammo_type),
class: "mx-4 my-2 btn btn-primary",
data: [qa: "details"]
) %>
<%= live_patch to: Routes.ammo_group_show_path(Endpoint, :edit, @ammo_group),
class: "mx-4 my-2 text-primary-500 link",
data: [qa: "edit"] do %>
<i class="fa-fw fa-lg fas fa-edit"></i>
<% end %>
<%= live_patch to: Routes.ammo_group_show_path(Endpoint, :edit, @ammo_group),
class: "mx-4 my-2 text-primary-500 link",
data: [qa: "edit"] do %>
<i class="fa-fw fa-lg fas fa-edit"></i>
<% end %>
<%= link to: "#",
class: "mx-4 my-2 text-primary-500 link",
phx_click: "delete",
data: [
confirm: dgettext("prompts", "Are you sure you want to delete this ammo?"),
qa: "delete"
] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
<%= link to: "#",
class: "mx-4 my-2 text-primary-500 link",
phx_click: "delete",
data: [
confirm: dgettext("prompts", "Are you sure you want to delete this ammo?"),
qa: "delete"
] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
</div>
<button type="button" class="mx-4 my-2 btn btn-primary" phx-click="toggle_staged">
<%= if @ammo_group.staged, do: gettext("Unstage from range"), else: gettext("Stage for range") %>
</button>
<div class="flex flex-wrap justify-center items-center text-primary-500">
<button type="button" class="mx-4 my-2 btn btn-primary" phx-click="toggle_staged">
<%= if @ammo_group.staged, do: gettext("Unstage from range"), else: gettext("Stage for range") %>
</button>
<%= live_patch(dgettext("actions", "Move to different container"),
to: Routes.ammo_group_show_path(Endpoint, :move, @ammo_group),
class: "btn btn-primary",
data: [qa: "move"]
) %>
<%= live_patch(dgettext("actions", "Move containers"),
to: Routes.ammo_group_show_path(Endpoint, :move, @ammo_group),
class: "btn btn-primary",
data: [qa: "move"]
) %>
<%= live_patch(dgettext("actions", "Record shots"),
to: Routes.ammo_group_show_path(Endpoint, :add_shot_group, @ammo_group),
class: "mx-4 my-2 btn btn-primary"
) %>
</div>
</div>
<hr class="mb-4 w-full">