add adding shots to ammo group index and show page

This commit is contained in:
shibao 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,6 +70,7 @@
</td>
<td class="p-2">
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
<button
type="button"
class="btn btn-primary"
@ -78,6 +79,12 @@
>
<%= 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,6 +24,7 @@
<% end %>
</div>
<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),
@ -46,16 +47,24 @@
] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
</div>
<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"),
<%= 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">

View File

@ -11,7 +11,7 @@ msgid ""
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:34
#: lib/cannery_web/live/ammo_group_live/index.ex:42
msgid "Add Ammo"
msgstr ""
@ -160,12 +160,14 @@ msgid "Why not get some ready to shoot?"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:83
#: lib/cannery_web/live/ammo_group_live/show.html.heex:63
#: lib/cannery_web/live/range_live/index.html.heex:34
msgid "Record shots"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.html.heex:28
#: lib/cannery_web/live/ammo_group_live/show.html.heex:29
msgid "Ammo Details"
msgstr ""
@ -175,8 +177,8 @@ msgid "Add another container!"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.html.heex:54
msgid "Move to different container"
#: lib/cannery_web/live/ammo_group_live/show.html.heex:57
msgid "Move containers"
msgstr ""
#, elixir-autogen, elixir-format

View File

@ -154,7 +154,7 @@ msgid "Easy to Use:"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:28
#: lib/cannery_web/live/ammo_group_live/index.ex:36
#: lib/cannery_web/live/ammo_group_live/show.ex:55
msgid "Edit Ammo group"
msgstr ""
@ -459,7 +459,7 @@ msgid "Steel"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.html.heex:66
#: lib/cannery_web/live/ammo_group_live/show.html.heex:75
msgid "Stored in"
msgstr ""
@ -486,7 +486,7 @@ msgid "The self-hosted firearm tracker website"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.html.heex:71
#: lib/cannery_web/live/ammo_group_live/show.html.heex:80
msgid "This ammo group is not in a container"
msgstr ""
@ -545,6 +545,7 @@ msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/components/topbar.ex:63
#: lib/cannery_web/live/ammo_group_live/index.html.heex:39
msgid "Range"
msgstr ""
@ -569,13 +570,13 @@ msgid "No ammo staged"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.html.heex:51
#: lib/cannery_web/live/ammo_group_live/show.html.heex:54
#: lib/cannery_web/live/range_live/index.html.heex:31
msgid "Stage for range"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.html.heex:51
#: lib/cannery_web/live/ammo_group_live/show.html.heex:54
#: lib/cannery_web/live/range_live/index.html.heex:31
msgid "Unstage from range"
msgstr ""
@ -587,6 +588,7 @@ msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/components/add_shot_group_component.html.heex:3
#: lib/cannery_web/live/ammo_group_live/index.ex:24
#: lib/cannery_web/live/range_live/index.ex:28
msgid "Record shots"
msgstr ""
@ -597,7 +599,7 @@ msgid "Ammo Types"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:39
#: lib/cannery_web/live/ammo_group_live/index.ex:47
msgid "Ammo groups"
msgstr ""
@ -638,7 +640,7 @@ msgid "Shot Records"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:22
#: lib/cannery_web/live/ammo_group_live/index.ex:30
#: lib/cannery_web/live/ammo_group_live/show.ex:53
msgid "Move Ammo group"
msgstr ""
@ -722,17 +724,12 @@ msgid "New password"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:79
#: lib/cannery_web/live/ammo_group_live/index.html.heex:80
msgid "Stage"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:39
msgid "Staged for Range"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:79
#: lib/cannery_web/live/ammo_group_live/index.html.heex:80
msgid "Unstage"
msgstr ""

View File

@ -67,7 +67,7 @@ msgid "Ammo group created successfully"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:46
#: lib/cannery_web/live/ammo_group_live/index.ex:54
#: lib/cannery_web/live/ammo_group_live/show.ex:34
msgid "Ammo group deleted succesfully"
msgstr ""
@ -97,8 +97,8 @@ msgid "Are you sure you want to delete the invite for %{name}?"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:111
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
#: lib/cannery_web/live/ammo_group_live/index.html.heex:118
#: lib/cannery_web/live/ammo_group_live/show.html.heex:45
#: lib/cannery_web/live/ammo_type_live/index.html.heex:68
msgid "Are you sure you want to delete this ammo?"
msgstr ""