add adding shots to ammo group index and show page
This commit is contained in:
		| @@ -17,6 +17,14 @@ defmodule CanneryWeb.AmmoGroupLive.Index do | |||||||
|     {:noreply, apply_action(socket, live_action, params)} |     {:noreply, apply_action(socket, live_action, params)} | ||||||
|   end |   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 |   defp apply_action(%{assigns: %{current_user: current_user}} = socket, :move, %{"id" => id}) do | ||||||
|     socket |     socket | ||||||
|     |> assign(:page_title, gettext("Move Ammo group")) |     |> assign(:page_title, gettext("Move Ammo group")) | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ | |||||||
|               <%= gettext("Notes") %> |               <%= gettext("Notes") %> | ||||||
|             </th> |             </th> | ||||||
|             <th class="p-2"> |             <th class="p-2"> | ||||||
|               <%= gettext("Staged for Range") %> |               <%= gettext("Range") %> | ||||||
|             </th> |             </th> | ||||||
|             <th class="p-2"> |             <th class="p-2"> | ||||||
|               <%= gettext("Container") %> |               <%= gettext("Container") %> | ||||||
| @@ -70,6 +70,7 @@ | |||||||
|               </td> |               </td> | ||||||
|  |  | ||||||
|               <td class="p-2"> |               <td class="p-2"> | ||||||
|  |                 <div class="px-4 py-2 space-x-4 flex justify-center items-center"> | ||||||
|                   <button |                   <button | ||||||
|                     type="button" |                     type="button" | ||||||
|                     class="btn btn-primary" |                     class="btn btn-primary" | ||||||
| @@ -78,6 +79,12 @@ | |||||||
|                   > |                   > | ||||||
|                     <%= if ammo_group.staged, do: gettext("Unstage"), else: gettext("Stage") %> |                     <%= if ammo_group.staged, do: gettext("Unstage"), else: gettext("Stage") %> | ||||||
|                   </button> |                   </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> | ||||||
|  |  | ||||||
|               <td class="p-2"> |               <td class="p-2"> | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ | |||||||
|     <% end %> |     <% end %> | ||||||
|   </div> |   </div> | ||||||
|  |  | ||||||
|  |   <div class="flex flex-col justify-center items-center"> | ||||||
|     <div class="flex flex-wrap justify-center items-center text-primary-500"> |     <div class="flex flex-wrap justify-center items-center text-primary-500"> | ||||||
|       <%= live_patch(dgettext("actions", "Ammo Details"), |       <%= live_patch(dgettext("actions", "Ammo Details"), | ||||||
|         to: Routes.ammo_type_show_path(Endpoint, :show, @ammo_group.ammo_type), |         to: Routes.ammo_type_show_path(Endpoint, :show, @ammo_group.ammo_type), | ||||||
| @@ -46,16 +47,24 @@ | |||||||
|            ] do %> |            ] do %> | ||||||
|         <i class="fa-fw fa-lg fas fa-trash"></i> |         <i class="fa-fw fa-lg fas fa-trash"></i> | ||||||
|       <% end %> |       <% 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"> |       <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") %> |         <%= if @ammo_group.staged, do: gettext("Unstage from range"), else: gettext("Stage for range") %> | ||||||
|       </button> |       </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), |         to: Routes.ammo_group_show_path(Endpoint, :move, @ammo_group), | ||||||
|         class: "btn btn-primary", |         class: "btn btn-primary", | ||||||
|         data: [qa: "move"] |         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> |   </div> | ||||||
|  |  | ||||||
|   <hr class="mb-4 w-full"> |   <hr class="mb-4 w-full"> | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ msgid "" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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" | msgid "Add Ammo" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| @@ -160,12 +160,14 @@ msgid "Why not get some ready to shoot?" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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 | #: lib/cannery_web/live/range_live/index.html.heex:34 | ||||||
| msgid "Record shots" | msgid "Record shots" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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" | msgid "Ammo Details" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| @@ -175,8 +177,8 @@ msgid "Add another container!" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| #: lib/cannery_web/live/ammo_group_live/show.html.heex:54 | #: lib/cannery_web/live/ammo_group_live/show.html.heex:57 | ||||||
| msgid "Move to different container" | msgid "Move containers" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
|   | |||||||
| @@ -154,7 +154,7 @@ msgid "Easy to Use:" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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 | #: lib/cannery_web/live/ammo_group_live/show.ex:55 | ||||||
| msgid "Edit Ammo group" | msgid "Edit Ammo group" | ||||||
| msgstr "" | msgstr "" | ||||||
| @@ -459,7 +459,7 @@ msgid "Steel" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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" | msgid "Stored in" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| @@ -486,7 +486,7 @@ msgid "The self-hosted firearm tracker website" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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" | msgid "This ammo group is not in a container" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| @@ -545,6 +545,7 @@ msgstr "" | |||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| #: lib/cannery_web/components/topbar.ex:63 | #: lib/cannery_web/components/topbar.ex:63 | ||||||
|  | #: lib/cannery_web/live/ammo_group_live/index.html.heex:39 | ||||||
| msgid "Range" | msgid "Range" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| @@ -569,13 +570,13 @@ msgid "No ammo staged" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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 | #: lib/cannery_web/live/range_live/index.html.heex:31 | ||||||
| msgid "Stage for range" | msgid "Stage for range" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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 | #: lib/cannery_web/live/range_live/index.html.heex:31 | ||||||
| msgid "Unstage from range" | msgid "Unstage from range" | ||||||
| msgstr "" | msgstr "" | ||||||
| @@ -587,6 +588,7 @@ msgstr "" | |||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:3 | #: 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 | #: lib/cannery_web/live/range_live/index.ex:28 | ||||||
| msgid "Record shots" | msgid "Record shots" | ||||||
| msgstr "" | msgstr "" | ||||||
| @@ -597,7 +599,7 @@ msgid "Ammo Types" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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" | msgid "Ammo groups" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| @@ -638,7 +640,7 @@ msgid "Shot Records" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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 | #: lib/cannery_web/live/ammo_group_live/show.ex:53 | ||||||
| msgid "Move Ammo group" | msgid "Move Ammo group" | ||||||
| msgstr "" | msgstr "" | ||||||
| @@ -722,17 +724,12 @@ msgid "New password" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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" | msgid "Stage" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| #: lib/cannery_web/live/ammo_group_live/index.html.heex:39 | #: lib/cannery_web/live/ammo_group_live/index.html.heex:80 | ||||||
| msgid "Staged for Range" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| #: lib/cannery_web/live/ammo_group_live/index.html.heex:79 |  | ||||||
| msgid "Unstage" | msgid "Unstage" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -67,7 +67,7 @@ msgid "Ammo group created successfully" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, 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 | #: lib/cannery_web/live/ammo_group_live/show.ex:34 | ||||||
| msgid "Ammo group deleted succesfully" | msgid "Ammo group deleted succesfully" | ||||||
| msgstr "" | msgstr "" | ||||||
| @@ -97,8 +97,8 @@ msgid "Are you sure you want to delete the invite for %{name}?" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| #: lib/cannery_web/live/ammo_group_live/index.html.heex:111 | #: lib/cannery_web/live/ammo_group_live/index.html.heex:118 | ||||||
| #: lib/cannery_web/live/ammo_group_live/show.html.heex:44 | #: lib/cannery_web/live/ammo_group_live/show.html.heex:45 | ||||||
| #: lib/cannery_web/live/ammo_type_live/index.html.heex:68 | #: lib/cannery_web/live/ammo_type_live/index.html.heex:68 | ||||||
| msgid "Are you sure you want to delete this ammo?" | msgid "Are you sure you want to delete this ammo?" | ||||||
| msgstr "" | msgstr "" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user