Compare commits

..

No commits in common. "a6b2c6181e8f12f50d9bcee43fad07d5a923b58c" and "91cf9d0eb59228777de7d63450716091a57bea94" have entirely different histories.

25 changed files with 155 additions and 550 deletions

View File

@ -1,10 +1,3 @@
# v0.3.0
- Fix ammo type counts not showing when count is 0
- Add prompt to create first container before first ammo group
- Edit and delete shot groups from ammo group show page
- Use today's date when adding new shot groups
- Create multiple ammo groups at one time
# v0.2.3 # v0.2.3
- Fix modals with overflowing forms - Fix modals with overflowing forms
- Fix grids having uneven margins in phone mode - Fix grids having uneven margins in phone mode

View File

@ -6,9 +6,7 @@ defmodule Cannery.Ammo do
import Ecto.Query, warn: false import Ecto.Query, warn: false
alias Cannery.{Accounts.User, Containers, Repo} alias Cannery.{Accounts.User, Containers, Repo}
alias Cannery.Ammo.{AmmoGroup, AmmoType} alias Cannery.Ammo.{AmmoGroup, AmmoType}
alias Ecto.{Changeset, Multi} alias Ecto.Changeset
@ammo_group_create_limit 10_000
@doc """ @doc """
Returns the list of ammo_types. Returns the list of ammo_types.
@ -92,7 +90,7 @@ defmodule Cannery.Ammo do
from ag in AmmoGroup, from ag in AmmoGroup,
where: ag.ammo_type_id == ^ammo_type_id, where: ag.ammo_type_id == ^ammo_type_id,
select: sum(ag.count) select: sum(ag.count)
) || 0 )
end end
@doc """ @doc """
@ -119,7 +117,7 @@ defmodule Cannery.Ammo do
left_join: sg in assoc(ag, :shot_groups), left_join: sg in assoc(ag, :shot_groups),
where: ag.ammo_type_id == ^ammo_type_id, where: ag.ammo_type_id == ^ammo_type_id,
select: sum(sg.count) select: sum(sg.count)
) || 0 )
end end
@doc """ @doc """
@ -329,63 +327,36 @@ defmodule Cannery.Ammo do
end end
@doc """ @doc """
Creates multiple ammo_groups at once. Creates a ammo_group.
## Examples ## Examples
iex> create_ammo_groups(%{field: value}, 3, %User{id: 123}) iex> create_ammo_group(%{field: value}, %User{id: 123})
{:ok, {3, [%AmmoGroup{}]}} {:ok, %AmmoGroup{}}
iex> create_ammo_groups(%{field: bad_value}, 3, %User{id: 123}) iex> create_ammo_group(%{field: bad_value}, %User{id: 123})
{:error, %Changeset{}} {:error, %Changeset{}}
""" """
@spec create_ammo_groups(attrs :: map(), multiplier :: non_neg_integer(), User.t()) :: @spec create_ammo_group(attrs :: map(), User.t()) ::
{:ok, {count :: non_neg_integer(), [AmmoGroup.t()] | nil}} {:ok, AmmoGroup.t()} | {:error, Changeset.t(AmmoGroup.new_ammo_group())}
| {:error, Changeset.t(AmmoGroup.new_ammo_group()) | nil} def create_ammo_group(
def create_ammo_groups(
%{"ammo_type_id" => ammo_type_id, "container_id" => container_id} = attrs, %{"ammo_type_id" => ammo_type_id, "container_id" => container_id} = attrs,
multiplier,
%User{id: user_id} = user %User{id: user_id} = user
) ) do
when multiplier >= 1 and multiplier <= @ammo_group_create_limit do
# validate ammo type and container ids belong to user # validate ammo type and container ids belong to user
_valid_ammo_type = get_ammo_type!(ammo_type_id, user) _valid_ammo_type = get_ammo_type!(ammo_type_id, user)
_valid_container = Containers.get_container!(container_id, user) _valid_container = Containers.get_container!(container_id, user)
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second) %AmmoGroup{}
|> AmmoGroup.create_changeset(attrs |> Map.put("user_id", user_id))
changesets = |> Repo.insert()
Enum.map(1..multiplier, fn _count ->
%AmmoGroup{} |> AmmoGroup.create_changeset(attrs |> Map.put("user_id", user_id))
end)
if changesets |> Enum.all?(fn %{valid?: valid} -> valid end) do
Multi.new()
|> Multi.insert_all(
:create_ammo_groups,
AmmoGroup,
changesets
|> Enum.map(fn changeset ->
changeset
|> Map.get(:changes)
|> Map.merge(%{inserted_at: now, updated_at: now})
end),
returning: true
)
|> Repo.transaction()
|> case do
{:ok, %{create_ammo_groups: {count, ammo_groups}}} -> {:ok, {count, ammo_groups}}
{:error, :create_ammo_groups, changeset, _changes_so_far} -> {:error, changeset}
{:error, _other_transaction, _value, _changes_so_far} -> {:error, nil}
end
else
{:error, changesets |> List.first()}
end
end end
def create_ammo_groups(invalid_attrs, _multiplier, _user) do def create_ammo_group(invalid_attrs, _user) do
{:error, %AmmoGroup{} |> AmmoGroup.create_changeset(invalid_attrs)} %AmmoGroup{}
|> AmmoGroup.create_changeset(invalid_attrs |> Map.put("user_id", "-1"))
|> Repo.insert()
end end
@doc """ @doc """

View File

@ -36,11 +36,7 @@
<%= error_tag(f, :notes, "col-span-3") %> <%= error_tag(f, :notes, "col-span-3") %>
<%= label(f, :date, gettext("Date (UTC)"), class: "title text-lg text-primary-600") %> <%= label(f, :date, gettext("Date (UTC)"), class: "title text-lg text-primary-600") %>
<%= date_input(f, :date, <%= date_input(f, :date, class: "input input-primary col-span-2") %>
class: "input input-primary col-span-2",
phx_update: "ignore",
value: Date.utc_today()
) %>
<%= error_tag(f, :notes, "col-span-3") %> <%= error_tag(f, :notes, "col-span-3") %>
<%= submit(dgettext("actions", "Save"), <%= submit(dgettext("actions", "Save"),

View File

@ -9,8 +9,6 @@ defmodule CanneryWeb.AmmoGroupLive.FormComponent do
alias Ecto.Changeset alias Ecto.Changeset
alias Phoenix.LiveView.Socket alias Phoenix.LiveView.Socket
@ammo_group_create_limit 10_000
@impl true @impl true
@spec update( @spec update(
%{:ammo_group => AmmoGroup.t(), :current_user => User.t(), optional(any) => any}, %{:ammo_group => AmmoGroup.t(), :current_user => User.t(), optional(any) => any},
@ -22,14 +20,10 @@ defmodule CanneryWeb.AmmoGroupLive.FormComponent do
@spec update(Socket.t()) :: {:ok, Socket.t()} @spec update(Socket.t()) :: {:ok, Socket.t()}
def update(%{assigns: %{ammo_group: ammo_group, current_user: current_user}} = socket) do def update(%{assigns: %{ammo_group: ammo_group, current_user: current_user}} = socket) do
socket = changeset = Ammo.change_ammo_group(ammo_group)
socket containers = Containers.list_containers(current_user)
|> assign(:ammo_group_create_limit, @ammo_group_create_limit) ammo_types = Ammo.list_ammo_types(current_user)
|> assign(:changeset, Ammo.change_ammo_group(ammo_group)) {:ok, socket |> assign(changeset: changeset, containers: containers, ammo_types: ammo_types)}
|> assign(:ammo_types, Ammo.list_ammo_types(current_user))
|> assign_new(:containers, fn -> Containers.list_containers(current_user) end)
{:ok, socket}
end end
@impl true @impl true
@ -83,68 +77,20 @@ defmodule CanneryWeb.AmmoGroupLive.FormComponent do
end end
defp save_ammo_group( defp save_ammo_group(
%{assigns: %{changeset: changeset}} = socket, %{assigns: %{current_user: current_user, return_to: return_to}} = socket,
:new, :new,
%{"multiplier" => multiplier_str} = ammo_group_params ammo_group_params
) do ) do
socket = socket =
case multiplier_str |> Integer.parse() do case Ammo.create_ammo_group(ammo_group_params, current_user) do
{multiplier, _remainder} {:ok, _ammo_group} ->
when multiplier >= 1 and multiplier <= @ammo_group_create_limit -> prompt = dgettext("prompts", "Ammo group created successfully")
socket |> create_multiple(ammo_group_params, multiplier)
{multiplier, _remainder} ->
error_msg =
dgettext(
"errors",
"Invalid number of copies, must be between 1 and %{max}. Was %{multiplier}",
max: @ammo_group_create_limit,
multiplier: multiplier
)
{:error, changeset} =
changeset
|> Changeset.add_error(:multiplier, error_msg)
|> Changeset.apply_action(:insert)
socket |> assign(:changeset, changeset)
:error ->
error_msg = dgettext("errors", "Could not parse number of copies")
{:error, changeset} =
changeset
|> Changeset.add_error(:multiplier, error_msg)
|> Changeset.apply_action(:insert)
socket |> assign(:changeset, changeset)
end
{:noreply, socket}
end
defp create_multiple(
%{assigns: %{current_user: current_user, return_to: return_to}} = socket,
ammo_group_params,
multiplier
) do
case Ammo.create_ammo_groups(ammo_group_params, multiplier, current_user) do
{:ok, {count, _ammo_groups}} ->
prompt =
dngettext(
"prompts",
"Ammo group created successfully",
"Ammo groups created successfully",
count
)
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to) socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
{:error, %Changeset{} = changeset} -> {:error, %Changeset{} = changeset} ->
socket |> assign(changeset: changeset) socket |> assign(changeset: changeset)
end
{:error, nil} -> {:noreply, socket}
socket
end
end end
end end

View File

@ -33,7 +33,7 @@
<%= label(f, :price_paid, gettext("Price paid"), class: "title text-lg text-primary-600") %> <%= label(f, :price_paid, gettext("Price paid"), class: "title text-lg text-primary-600") %>
<%= number_input(f, :price_paid, <%= number_input(f, :price_paid,
step: 0.01, step: "0.01",
class: "text-center col-span-2 input input-primary" class: "text-center col-span-2 input input-primary"
) %> ) %>
<%= error_tag(f, :price_paid, "col-span-3 text-center") %> <%= error_tag(f, :price_paid, "col-span-3 text-center") %>
@ -51,29 +51,9 @@
) %> ) %>
<%= error_tag(f, :container_id, "col-span-3 text-center") %> <%= error_tag(f, :container_id, "col-span-3 text-center") %>
<%= case @action do %>
<% :new -> %>
<hr class="hr col-span-3" />
<%= label(f, :multiplier, gettext("Copies"), class: "title text-lg text-primary-600") %>
<%= number_input(f, :multiplier,
max: @ammo_group_create_limit,
class: "text-center input input-primary",
value: 1,
phx_update: "ignore"
) %>
<%= submit(dgettext("actions", "Create"),
phx_disable_with: dgettext("prompts", "Creating..."),
class: "mx-auto btn btn-primary"
) %>
<%= error_tag(f, :multiplier, "col-span-3 text-center") %>
<% :edit -> %>
<%= submit(dgettext("actions", "Save"), <%= submit(dgettext("actions", "Save"),
phx_disable_with: dgettext("prompts", "Saving..."), phx_disable_with: dgettext("prompts", "Saving..."),
class: "mx-auto col-span-3 btn btn-primary" class: "mx-auto col-span-3 btn btn-primary"
) %> ) %>
<% end %>
</.form> </.form>
</div> </div>

View File

@ -4,7 +4,7 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
""" """
use CanneryWeb, :live_view use CanneryWeb, :live_view
alias Cannery.{Ammo, Ammo.AmmoGroup, Containers, Repo} alias Cannery.{Ammo, Ammo.AmmoGroup, Repo}
alias CanneryWeb.Endpoint alias CanneryWeb.Endpoint
@impl true @impl true
@ -17,11 +17,9 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
{:noreply, apply_action(socket, live_action, params)} {:noreply, apply_action(socket, live_action, params)}
end end
defp apply_action( defp apply_action(%{assigns: %{current_user: current_user}} = socket, :add_shot_group, %{
%{assigns: %{current_user: current_user}} = socket, "id" => id
:add_shot_group, }) do
%{"id" => id}
) do
socket socket
|> assign(:page_title, gettext("Record shots")) |> assign(:page_title, gettext("Record shots"))
|> assign(:ammo_group, Ammo.get_ammo_group!(id, current_user)) |> assign(:ammo_group, Ammo.get_ammo_group!(id, current_user))
@ -74,7 +72,6 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
defp display_ammo_groups(%{assigns: %{current_user: current_user}} = socket) do defp display_ammo_groups(%{assigns: %{current_user: current_user}} = socket) do
ammo_groups = Ammo.list_ammo_groups(current_user) |> Repo.preload([:ammo_type, :container]) ammo_groups = Ammo.list_ammo_groups(current_user) |> Repo.preload([:ammo_type, :container])
containers = Containers.list_containers(current_user) socket |> assign(:ammo_groups, ammo_groups)
socket |> assign(ammo_groups: ammo_groups, containers: containers)
end end
end end

View File

@ -9,41 +9,15 @@
<%= display_emoji("😔") %> <%= display_emoji("😔") %>
</h2> </h2>
<%= if @containers |> Enum.empty?() do %>
<div class="flex justify-center items-center">
<h2 class="m-2 title text-md text-primary-600">
<%= dgettext("prompts", "You'll need to") %>
</h2>
<%= live_patch(dgettext("actions", "add a container first"),
to: Routes.container_index_path(Endpoint, :new),
class: "btn btn-primary"
) %>
</div>
<% else %>
<%= live_patch(dgettext("actions", "Add your first box!"), <%= live_patch(dgettext("actions", "Add your first box!"),
to: Routes.ammo_group_index_path(Endpoint, :new), to: Routes.ammo_group_index_path(Endpoint, :new),
class: "btn btn-primary" class: "btn btn-primary"
) %> ) %>
<% end %>
<% else %>
<%= if @containers |> Enum.empty?() do %>
<div class="flex justify-center items-center">
<h2 class="m-2 title text-md text-primary-600">
<%= dgettext("prompts", "You'll need to") %>
</h2>
<%= live_patch(dgettext("actions", "add a container first"),
to: Routes.container_index_path(Endpoint, :new),
class: "btn btn-primary"
) %>
</div>
<% else %> <% else %>
<%= live_patch(dgettext("actions", "New Ammo group"), <%= live_patch(dgettext("actions", "New Ammo group"),
to: Routes.ammo_group_index_path(Endpoint, :new), to: Routes.ammo_group_index_path(Endpoint, :new),
class: "btn btn-primary" class: "btn btn-primary"
) %> ) %>
<% end %>
<div class="w-full overflow-x-auto border border-gray-600 rounded-lg shadow-lg bg-black"> <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"> <table class="min-w-full table-auto text-center bg-white">
@ -169,7 +143,6 @@
ammo_group={@ammo_group} ammo_group={@ammo_group}
return_to={Routes.ammo_group_index_path(Endpoint, :index)} return_to={Routes.ammo_group_index_path(Endpoint, :index)}
current_user={@current_user} current_user={@current_user}
containers={@containers}
/> />
</.modal> </.modal>
<% @live_action == :add_shot_group -> %> <% @live_action == :add_shot_group -> %>

View File

@ -5,9 +5,8 @@ defmodule CanneryWeb.AmmoGroupLive.Show do
use CanneryWeb, :live_view use CanneryWeb, :live_view
import CanneryWeb.Components.ContainerCard import CanneryWeb.Components.ContainerCard
alias Cannery.{ActivityLog, Ammo, Ammo.AmmoGroup, Repo} alias Cannery.{Ammo, Repo}
alias CanneryWeb.Endpoint alias CanneryWeb.Endpoint
alias Phoenix.LiveView.Socket
@impl true @impl true
def mount(_params, session, socket) do def mount(_params, session, socket) do
@ -16,31 +15,14 @@ defmodule CanneryWeb.AmmoGroupLive.Show do
@impl true @impl true
def handle_params( def handle_params(
%{"id" => id, "shot_group_id" => shot_group_id}, %{"id" => id},
_url, _url,
%{assigns: %{live_action: live_action, current_user: current_user}} = socket %{assigns: %{live_action: live_action, current_user: current_user}} = socket
) do ) do
shot_group = ActivityLog.get_shot_group!(shot_group_id, current_user) ammo_group = Ammo.get_ammo_group!(id, current_user) |> Repo.preload([:container, :ammo_type])
{:noreply, socket |> assign(page_title: page_title(live_action), ammo_group: ammo_group)}
socket =
socket
|> assign(page_title: page_title(live_action), shot_group: shot_group)
|> display_ammo_group(id)
{:noreply, socket}
end end
@impl true
def handle_params(%{"id" => id}, _url, %{assigns: %{live_action: live_action}} = socket) do
{:noreply, socket |> assign(page_title: page_title(live_action)) |> display_ammo_group(id)}
end
defp page_title(:add_shot_group), do: gettext("Record Shots")
defp page_title(:edit_shot_group), do: gettext("Edit Shot Records")
defp page_title(:move), do: gettext("Move Ammo group")
defp page_title(:show), do: gettext("Show Ammo group")
defp page_title(:edit), do: gettext("Edit Ammo group")
@impl true @impl true
def handle_event( def handle_event(
"delete", "delete",
@ -64,29 +46,11 @@ defmodule CanneryWeb.AmmoGroupLive.Show do
{:ok, ammo_group} = {:ok, ammo_group} =
ammo_group |> Ammo.update_ammo_group(%{"staged" => !ammo_group.staged}, current_user) ammo_group |> Ammo.update_ammo_group(%{"staged" => !ammo_group.staged}, current_user)
{:noreply, socket |> display_ammo_group(ammo_group)} {:noreply, socket |> assign(ammo_group: ammo_group)}
end end
@impl true defp page_title(:add_shot_group), do: gettext("Add Shot group")
def handle_event( defp page_title(:move), do: gettext("Move Ammo group")
"delete_shot_group", defp page_title(:show), do: gettext("Show Ammo group")
%{"id" => id}, defp page_title(:edit), do: gettext("Edit Ammo group")
%{assigns: %{ammo_group: ammo_group, current_user: current_user}} = socket
) do
{:ok, _} =
ActivityLog.get_shot_group!(id, current_user)
|> ActivityLog.delete_shot_group(current_user)
prompt = dgettext("prompts", "Shot records deleted succesfully")
{:noreply, socket |> put_flash(:info, prompt) |> display_ammo_group(ammo_group)}
end
@spec display_ammo_group(Socket.t(), AmmoGroup.t() | AmmoGroup.id()) :: Socket.t()
defp display_ammo_group(socket, %AmmoGroup{} = ammo_group) do
ammo_group = ammo_group |> Repo.preload([:container, :ammo_type, :shot_groups], force: true)
socket |> assign(:ammo_group, ammo_group)
end
defp display_ammo_group(%{assigns: %{current_user: current_user}} = socket, id),
do: display_ammo_group(socket, Ammo.get_ammo_group!(id, current_user))
end end

View File

@ -124,8 +124,6 @@
<th class="p-2"> <th class="p-2">
<%= gettext("Date") %> <%= gettext("Date") %>
</th> </th>
<th class="p-2"></th>
</tr> </tr>
</thead> </thead>
<tbody id="shot_groups"> <tbody id="shot_groups">
@ -134,35 +132,12 @@
<td class="p-2"> <td class="p-2">
<%= shot_group.count %> <%= shot_group.count %>
</td> </td>
<td class="p-2"> <td class="p-2">
<%= shot_group.notes %> <%= shot_group.notes %>
</td> </td>
<td class="p-2"> <td class="p-2">
<%= shot_group.date |> display_date() %> <%= shot_group.date |> display_date() %>
</td> </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.ammo_group_show_path(Endpoint, :edit_shot_group, @ammo_group, 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_shot_group",
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> </tr>
<% end %> <% end %>
</tbody> </tbody>
@ -184,18 +159,6 @@
current_user={@current_user} current_user={@current_user}
/> />
</.modal> </.modal>
<% :edit_shot_group -> %>
<.modal return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}>
<.live_component
module={CanneryWeb.RangeLive.FormComponent}
id={@shot_group.id}
title={@page_title}
action={@live_action}
shot_group={@shot_group}
return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}
current_user={@current_user}
/>
</.modal>
<% :add_shot_group -> %> <% :add_shot_group -> %>
<.modal return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}> <.modal return_to={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}>
<.live_component <.live_component

View File

@ -100,8 +100,9 @@
) %> ) %>
</span> </span>
<% else %> <% else %>
<h3 class="mx-8 my-4 title text-lg text-primary-600 col-span-2"> <h3 class="title text-lg col-span-2">
<%= gettext("No cost information") %> <%= gettext("No cost information") %>
<%= display_emoji("😔") %>
</h3> </h3>
<% end %> <% end %>
</div> </div>
@ -110,10 +111,8 @@
<div> <div>
<%= if @ammo_groups |> Enum.empty?() do %> <%= if @ammo_groups |> Enum.empty?() do %>
<h2 class="mx-8 my-4 title text-lg text-primary-600">
<%= gettext("No ammo for this type") %> <%= gettext("No ammo for this type") %>
<%= display_emoji("😔") %> <%= display_emoji("😔") %>
</h2>
<% else %> <% else %>
<div class="flex flex-wrap justify-center items-center"> <div class="flex flex-wrap justify-center items-center">
<%= for ammo_group <- @ammo_groups do %> <%= for ammo_group <- @ammo_groups do %>

View File

@ -72,11 +72,9 @@
<hr class="mb-4 hr" /> <hr class="mb-4 hr" />
<div> <p>
<%= if @container.ammo_groups |> Enum.empty?() do %> <%= if @container.ammo_groups |> Enum.empty?() do %>
<h2 class="mx-8 my-4 title text-lg text-primary-600">
<%= gettext("No ammo groups in this container") %> <%= gettext("No ammo groups in this container") %>
</h2>
<% else %> <% else %>
<div class="flex flex-wrap justify-center items-center"> <div class="flex flex-wrap justify-center items-center">
<%= for ammo_group <- @container.ammo_groups do %> <%= for ammo_group <- @container.ammo_groups do %>
@ -84,7 +82,7 @@
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
</div> </p>
</div> </div>
<%= if @live_action in [:edit] do %> <%= if @live_action in [:edit] do %>

View File

@ -25,7 +25,7 @@ defmodule CanneryWeb.RangeLive.Index do
%{"id" => id} %{"id" => id}
) do ) do
socket socket
|> assign(:page_title, gettext("Record Shots")) |> assign(:page_title, gettext("Record shots"))
|> assign(:ammo_group, Ammo.get_ammo_group!(id, current_user)) |> assign(:ammo_group, Ammo.get_ammo_group!(id, current_user))
end end

View File

@ -80,7 +80,6 @@ defmodule CanneryWeb.Router do
live "/ammo_groups/:id/show/edit", AmmoGroupLive.Show, :edit live "/ammo_groups/:id/show/edit", AmmoGroupLive.Show, :edit
live "/ammo_groups/:id/show/add_shot_group", AmmoGroupLive.Show, :add_shot_group live "/ammo_groups/:id/show/add_shot_group", AmmoGroupLive.Show, :add_shot_group
live "/ammo_groups/:id/show/move", AmmoGroupLive.Show, :move live "/ammo_groups/:id/show/move", AmmoGroupLive.Show, :move
live "/ammo_groups/:id/show/:shot_group_id/edit", AmmoGroupLive.Show, :edit_shot_group
live "/range", RangeLive.Index, :index live "/range", RangeLive.Index, :index
live "/range/:id/edit", RangeLive.Index, :edit live "/range/:id/edit", RangeLive.Index, :edit

View File

@ -11,12 +11,12 @@ msgid ""
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:44 #: lib/cannery_web/live/ammo_group_live/index.ex:42
msgid "Add Ammo" msgid "Add Ammo"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:24 #: lib/cannery_web/live/ammo_group_live/index.html.heex:12
msgid "Add your first box!" msgid "Add your first box!"
msgstr "" msgstr ""
@ -81,7 +81,7 @@ msgid "Make your first tag!"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:42 #: lib/cannery_web/live/ammo_group_live/index.html.heex:17
msgid "New Ammo group" msgid "New Ammo group"
msgstr "" msgstr ""
@ -124,8 +124,8 @@ msgid "Reset password"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/components/add_shot_group_component.html.heex:46 #: lib/cannery_web/components/add_shot_group_component.html.heex:42
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:73 #: lib/cannery_web/live/ammo_group_live/form_component.html.heex:54
#: lib/cannery_web/live/ammo_type_live/form_component.html.heex:156 #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:156
#: lib/cannery_web/live/container_live/form_component.html.heex:50 #: lib/cannery_web/live/container_live/form_component.html.heex:50
#: lib/cannery_web/live/invite_live/form_component.html.heex:28 #: lib/cannery_web/live/invite_live/form_component.html.heex:28
@ -160,7 +160,7 @@ 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:111 #: lib/cannery_web/live/ammo_group_live/index.html.heex:85
#: lib/cannery_web/live/ammo_group_live/show.html.heex:86 #: lib/cannery_web/live/ammo_group_live/show.html.heex:86
#: lib/cannery_web/live/range_live/index.html.heex:36 #: lib/cannery_web/live/range_live/index.html.heex:36
msgid "Record shots" msgid "Record shots"
@ -190,14 +190,3 @@ msgstr ""
#: lib/cannery_web/live/invite_live/index.html.heex:33 #: lib/cannery_web/live/invite_live/index.html.heex:33
msgid "Copy to clipboard" msgid "Copy to clipboard"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:18
#: lib/cannery_web/live/ammo_group_live/index.html.heex:36
msgid "add a container first"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:66
msgid "Create"
msgstr ""

View File

@ -39,7 +39,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:21 #: lib/cannery_web/live/ammo_group_live/form_component.html.heex:21
#: lib/cannery_web/live/ammo_group_live/index.html.heex:53 #: lib/cannery_web/live/ammo_group_live/index.html.heex:27
msgid "Ammo type" msgid "Ammo type"
msgstr "" msgstr ""
@ -103,7 +103,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/components/move_ammo_group_component.html.heex:22 #: lib/cannery_web/components/move_ammo_group_component.html.heex:22
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:48 #: lib/cannery_web/live/ammo_group_live/form_component.html.heex:48
#: lib/cannery_web/live/ammo_group_live/index.html.heex:68 #: lib/cannery_web/live/ammo_group_live/index.html.heex:42
msgid "Container" msgid "Container"
msgstr "" msgstr ""
@ -122,7 +122,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:27 #: lib/cannery_web/live/ammo_group_live/form_component.html.heex:27
#: lib/cannery_web/live/ammo_group_live/index.html.heex:56 #: lib/cannery_web/live/ammo_group_live/index.html.heex:30
msgid "Count" msgid "Count"
msgstr "" msgstr ""
@ -155,8 +155,8 @@ msgid "Easy to Use:"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:38 #: lib/cannery_web/live/ammo_group_live/index.ex:36
#: lib/cannery_web/live/ammo_group_live/show.ex:42 #: lib/cannery_web/live/ammo_group_live/show.ex:55
msgid "Edit Ammo group" msgid "Edit Ammo group"
msgstr "" msgstr ""
@ -335,7 +335,7 @@ msgid "No ammo for this type"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/container_live/show.html.heex:78 #: lib/cannery_web/live/container_live/show.html.heex:77
msgid "No ammo groups in this container" msgid "No ammo groups in this container"
msgstr "" msgstr ""
@ -384,7 +384,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:34 #: lib/cannery_web/live/ammo_group_live/form_component.html.heex:34
#: lib/cannery_web/live/ammo_group_live/index.html.heex:59 #: lib/cannery_web/live/ammo_group_live/index.html.heex:33
msgid "Price paid" msgid "Price paid"
msgstr "" msgstr ""
@ -427,7 +427,7 @@ msgid "Settings"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.ex:41 #: lib/cannery_web/live/ammo_group_live/show.ex:54
msgid "Show Ammo group" msgid "Show Ammo group"
msgstr "" msgstr ""
@ -528,7 +528,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/components/topbar.ex:64 #: lib/cannery_web/components/topbar.ex:64
#: lib/cannery_web/live/ammo_group_live/index.html.heex:65 #: lib/cannery_web/live/ammo_group_live/index.html.heex:39
msgid "Range" msgid "Range"
msgstr "" msgstr ""
@ -565,9 +565,15 @@ msgstr ""
msgid "Unstage from range" msgid "Unstage from range"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.ex:52
msgid "Add Shot group"
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:26 #: lib/cannery_web/live/ammo_group_live/index.ex:24
#: lib/cannery_web/live/range_live/index.ex:28
msgid "Record shots" msgid "Record shots"
msgstr "" msgstr ""
@ -577,7 +583,7 @@ msgid "Ammo Types"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:49 #: lib/cannery_web/live/ammo_group_live/index.ex:47
msgid "Ammo groups" msgid "Ammo groups"
msgstr "" msgstr ""
@ -588,7 +594,6 @@ msgid "Date (UTC)"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.ex:39
#: lib/cannery_web/live/range_live/index.ex:34 #: lib/cannery_web/live/range_live/index.ex:34
msgid "Edit Shot Records" msgid "Edit Shot Records"
msgstr "" msgstr ""
@ -620,8 +625,8 @@ msgid "Shot Records"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:32 #: lib/cannery_web/live/ammo_group_live/index.ex:30
#: lib/cannery_web/live/ammo_group_live/show.ex:40 #: lib/cannery_web/live/ammo_group_live/show.ex:53
msgid "Move Ammo group" msgid "Move Ammo group"
msgstr "" msgstr ""
@ -642,7 +647,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/components/ammo_group_card.ex:43 #: lib/cannery_web/components/ammo_group_card.ex:43
#: lib/cannery_web/live/ammo_group_live/index.html.heex:90 #: lib/cannery_web/live/ammo_group_live/index.html.heex:64
#: lib/cannery_web/live/ammo_group_live/show.html.heex:32 #: lib/cannery_web/live/ammo_group_live/show.html.heex:32
#: lib/cannery_web/live/ammo_group_live/show.html.heex:39 #: lib/cannery_web/live/ammo_group_live/show.html.heex:39
#: lib/cannery_web/live/ammo_type_live/show.html.heex:98 #: lib/cannery_web/live/ammo_type_live/show.html.heex:98
@ -706,12 +711,12 @@ msgid "New password"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:108 #: lib/cannery_web/live/ammo_group_live/index.html.heex:82
msgid "Stage" msgid "Stage"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:108 #: lib/cannery_web/live/ammo_group_live/index.html.heex:82
msgid "Unstage" msgid "Unstage"
msgstr "" msgstr ""
@ -760,7 +765,7 @@ msgid "No cost information"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:62 #: lib/cannery_web/live/ammo_group_live/index.html.heex:36
msgid "% left" msgid "% left"
msgstr "" msgstr ""
@ -828,14 +833,3 @@ msgstr ""
#: lib/cannery_web/controllers/user_reset_password_controller.ex:36 #: lib/cannery_web/controllers/user_reset_password_controller.ex:36
msgid "Reset your password" msgid "Reset your password"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.ex:38
#: lib/cannery_web/live/range_live/index.ex:28
msgid "Record Shots"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:58
msgid "Copies"
msgstr ""

View File

@ -12,12 +12,12 @@ msgstr ""
"Plural-Forms: nplurals=2\n" "Plural-Forms: nplurals=2\n"
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:44 #: lib/cannery_web/live/ammo_group_live/index.ex:42
msgid "Add Ammo" msgid "Add Ammo"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:24 #: lib/cannery_web/live/ammo_group_live/index.html.heex:12
msgid "Add your first box!" msgid "Add your first box!"
msgstr "" msgstr ""
@ -82,7 +82,7 @@ msgid "Make your first tag!"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:42 #: lib/cannery_web/live/ammo_group_live/index.html.heex:17
msgid "New Ammo group" msgid "New Ammo group"
msgstr "" msgstr ""
@ -161,7 +161,7 @@ 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:111 #: lib/cannery_web/live/ammo_group_live/index.html.heex:85
#: lib/cannery_web/live/ammo_group_live/show.html.heex:86 #: lib/cannery_web/live/ammo_group_live/show.html.heex:86
#: lib/cannery_web/live/range_live/index.html.heex:36 #: lib/cannery_web/live/range_live/index.html.heex:36
msgid "Record shots" msgid "Record shots"
@ -191,9 +191,3 @@ msgstr ""
#: lib/cannery_web/live/invite_live/index.html.heex:33 #: lib/cannery_web/live/invite_live/index.html.heex:33
msgid "Copy to clipboard" msgid "Copy to clipboard"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:18
#: lib/cannery_web/live/ammo_group_live/index.html.heex:36
msgid "add a container first"
msgstr ""

View File

@ -40,7 +40,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:21 #: lib/cannery_web/live/ammo_group_live/form_component.html.heex:21
#: lib/cannery_web/live/ammo_group_live/index.html.heex:53 #: lib/cannery_web/live/ammo_group_live/index.html.heex:27
msgid "Ammo type" msgid "Ammo type"
msgstr "" msgstr ""
@ -104,7 +104,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/components/move_ammo_group_component.html.heex:22 #: lib/cannery_web/components/move_ammo_group_component.html.heex:22
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:48 #: lib/cannery_web/live/ammo_group_live/form_component.html.heex:48
#: lib/cannery_web/live/ammo_group_live/index.html.heex:68 #: lib/cannery_web/live/ammo_group_live/index.html.heex:42
msgid "Container" msgid "Container"
msgstr "" msgstr ""
@ -123,7 +123,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:27 #: lib/cannery_web/live/ammo_group_live/form_component.html.heex:27
#: lib/cannery_web/live/ammo_group_live/index.html.heex:56 #: lib/cannery_web/live/ammo_group_live/index.html.heex:30
msgid "Count" msgid "Count"
msgstr "" msgstr ""
@ -156,8 +156,8 @@ msgid "Easy to Use:"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:38 #: lib/cannery_web/live/ammo_group_live/index.ex:36
#: lib/cannery_web/live/ammo_group_live/show.ex:42 #: lib/cannery_web/live/ammo_group_live/show.ex:55
msgid "Edit Ammo group" msgid "Edit Ammo group"
msgstr "" msgstr ""
@ -336,7 +336,7 @@ msgid "No ammo for this type"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/container_live/show.html.heex:78 #: lib/cannery_web/live/container_live/show.html.heex:77
msgid "No ammo groups in this container" msgid "No ammo groups in this container"
msgstr "" msgstr ""
@ -385,7 +385,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:34 #: lib/cannery_web/live/ammo_group_live/form_component.html.heex:34
#: lib/cannery_web/live/ammo_group_live/index.html.heex:59 #: lib/cannery_web/live/ammo_group_live/index.html.heex:33
msgid "Price paid" msgid "Price paid"
msgstr "" msgstr ""
@ -428,7 +428,7 @@ msgid "Settings"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.ex:41 #: lib/cannery_web/live/ammo_group_live/show.ex:54
msgid "Show Ammo group" msgid "Show Ammo group"
msgstr "" msgstr ""
@ -529,7 +529,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/components/topbar.ex:64 #: lib/cannery_web/components/topbar.ex:64
#: lib/cannery_web/live/ammo_group_live/index.html.heex:65 #: lib/cannery_web/live/ammo_group_live/index.html.heex:39
msgid "Range" msgid "Range"
msgstr "" msgstr ""
@ -566,9 +566,15 @@ msgstr ""
msgid "Unstage from range" msgid "Unstage from range"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.ex:52
msgid "Add Shot group"
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:26 #: lib/cannery_web/live/ammo_group_live/index.ex:24
#: lib/cannery_web/live/range_live/index.ex:28
msgid "Record shots" msgid "Record shots"
msgstr "" msgstr ""
@ -578,7 +584,7 @@ msgid "Ammo Types"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:49 #: lib/cannery_web/live/ammo_group_live/index.ex:47
msgid "Ammo groups" msgid "Ammo groups"
msgstr "" msgstr ""
@ -589,7 +595,6 @@ msgid "Date (UTC)"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.ex:39
#: lib/cannery_web/live/range_live/index.ex:34 #: lib/cannery_web/live/range_live/index.ex:34
msgid "Edit Shot Records" msgid "Edit Shot Records"
msgstr "" msgstr ""
@ -621,8 +626,8 @@ msgid "Shot Records"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:32 #: lib/cannery_web/live/ammo_group_live/index.ex:30
#: lib/cannery_web/live/ammo_group_live/show.ex:40 #: lib/cannery_web/live/ammo_group_live/show.ex:53
msgid "Move Ammo group" msgid "Move Ammo group"
msgstr "" msgstr ""
@ -643,7 +648,7 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/components/ammo_group_card.ex:43 #: lib/cannery_web/components/ammo_group_card.ex:43
#: lib/cannery_web/live/ammo_group_live/index.html.heex:90 #: lib/cannery_web/live/ammo_group_live/index.html.heex:64
#: lib/cannery_web/live/ammo_group_live/show.html.heex:32 #: lib/cannery_web/live/ammo_group_live/show.html.heex:32
#: lib/cannery_web/live/ammo_group_live/show.html.heex:39 #: lib/cannery_web/live/ammo_group_live/show.html.heex:39
#: lib/cannery_web/live/ammo_type_live/show.html.heex:98 #: lib/cannery_web/live/ammo_type_live/show.html.heex:98
@ -707,12 +712,12 @@ msgid "New password"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:108 #: lib/cannery_web/live/ammo_group_live/index.html.heex:82
msgid "Stage" msgid "Stage"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:108 #: lib/cannery_web/live/ammo_group_live/index.html.heex:82
msgid "Unstage" msgid "Unstage"
msgstr "" msgstr ""
@ -761,7 +766,7 @@ msgid "No cost information"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:62 #: lib/cannery_web/live/ammo_group_live/index.html.heex:36
msgid "% left" msgid "% left"
msgstr "" msgstr ""
@ -829,9 +834,3 @@ msgstr ""
#: lib/cannery_web/controllers/user_reset_password_controller.ex:36 #: lib/cannery_web/controllers/user_reset_password_controller.ex:36
msgid "Reset your password" msgid "Reset your password"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format, fuzzy
#: lib/cannery_web/live/ammo_group_live/show.ex:38
#: lib/cannery_web/live/range_live/index.ex:28
msgid "Record Shots"
msgstr ""

View File

@ -63,18 +63,18 @@ msgid "A link to confirm your email change has been sent to the new address."
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.ex:90 #: lib/cannery_web/live/ammo_group_live/form_component.ex:87
msgid "Ammo group created successfully" msgid "Ammo group created successfully"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:56 #: lib/cannery_web/live/ammo_group_live/index.ex:54
#: lib/cannery_web/live/ammo_group_live/show.ex:52 #: lib/cannery_web/live/ammo_group_live/show.ex:34
msgid "Ammo group deleted succesfully" msgid "Ammo group deleted succesfully"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.ex:72 #: lib/cannery_web/live/ammo_group_live/form_component.ex:69
msgid "Ammo group updated successfully" msgid "Ammo group updated successfully"
msgstr "" msgstr ""
@ -98,7 +98,7 @@ 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:146 #: lib/cannery_web/live/ammo_group_live/index.html.heex:120
#: lib/cannery_web/live/ammo_group_live/show.html.heex:66 #: lib/cannery_web/live/ammo_group_live/show.html.heex:66
#: lib/cannery_web/live/ammo_type_live/index.html.heex:75 #: lib/cannery_web/live/ammo_type_live/index.html.heex:75
msgid "Are you sure you want to delete this ammo?" msgid "Are you sure you want to delete this ammo?"
@ -211,13 +211,11 @@ msgid "Ammo group unstaged succesfully"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.html.heex:159
#: lib/cannery_web/live/range_live/index.html.heex:108 #: lib/cannery_web/live/range_live/index.html.heex:108
msgid "Are you sure you want to delete this shot record?" msgid "Are you sure you want to delete this shot record?"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.ex:80
#: lib/cannery_web/live/range_live/index.ex:56 #: lib/cannery_web/live/range_live/index.ex:56
msgid "Shot records deleted succesfully" msgid "Shot records deleted succesfully"
msgstr "" msgstr ""
@ -246,9 +244,3 @@ msgstr ""
#: lib/cannery_web/live/container_live/edit_tags_component.ex:58 #: lib/cannery_web/live/container_live/edit_tags_component.ex:58
msgid "%{name} removed successfully" msgid "%{name} removed successfully"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:15
#: lib/cannery_web/live/ammo_group_live/index.html.heex:33
msgid "You'll need to"
msgstr ""

View File

@ -157,13 +157,3 @@ msgstr ""
#: lib/cannery_web/live/container_live/edit_tags_component.ex:52 #: lib/cannery_web/live/container_live/edit_tags_component.ex:52
msgid "Tag could not be removed" msgid "Tag could not be removed"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.ex:113
msgid "Could not parse number of copies"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.ex:98
msgid "Invalid number of copies, must be between 1 and %{max}. Was %{multiplier}"
msgstr ""

View File

@ -62,13 +62,18 @@ msgid "A link to confirm your email change has been sent to the new address."
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.ex:56 #: lib/cannery_web/live/ammo_group_live/form_component.ex:87
#: lib/cannery_web/live/ammo_group_live/show.ex:52 msgid "Ammo group created successfully"
msgstr ""
#, elixir-autogen, elixir-format
#: 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" msgid "Ammo group deleted succesfully"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.ex:75 #: lib/cannery_web/live/ammo_group_live/form_component.ex:69
msgid "Ammo group updated successfully" msgid "Ammo group updated successfully"
msgstr "" msgstr ""
@ -92,7 +97,7 @@ 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:146 #: lib/cannery_web/live/ammo_group_live/index.html.heex:120
#: lib/cannery_web/live/ammo_group_live/show.html.heex:66 #: lib/cannery_web/live/ammo_group_live/show.html.heex:66
#: lib/cannery_web/live/ammo_type_live/index.html.heex:75 #: lib/cannery_web/live/ammo_type_live/index.html.heex:75
msgid "Are you sure you want to delete this ammo?" msgid "Are you sure you want to delete this ammo?"
@ -154,8 +159,8 @@ msgid "Register to setup %{name}"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/components/add_shot_group_component.html.heex:48 #: lib/cannery_web/components/add_shot_group_component.html.heex:44
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:74 #: lib/cannery_web/live/ammo_group_live/form_component.html.heex:55
#: lib/cannery_web/live/ammo_type_live/form_component.html.heex:157 #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:157
#: lib/cannery_web/live/container_live/form_component.html.heex:52 #: lib/cannery_web/live/container_live/form_component.html.heex:52
#: lib/cannery_web/live/invite_live/form_component.html.heex:30 #: lib/cannery_web/live/invite_live/form_component.html.heex:30
@ -205,13 +210,11 @@ msgid "Ammo group unstaged succesfully"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.html.heex:159
#: lib/cannery_web/live/range_live/index.html.heex:108 #: lib/cannery_web/live/range_live/index.html.heex:108
msgid "Are you sure you want to delete this shot record?" msgid "Are you sure you want to delete this shot record?"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/show.ex:80
#: lib/cannery_web/live/range_live/index.ex:56 #: lib/cannery_web/live/range_live/index.ex:56
msgid "Shot records deleted succesfully" msgid "Shot records deleted succesfully"
msgstr "" msgstr ""
@ -240,21 +243,3 @@ msgstr ""
#: lib/cannery_web/live/container_live/edit_tags_component.ex:58 #: lib/cannery_web/live/container_live/edit_tags_component.ex:58
msgid "%{name} removed successfully" msgid "%{name} removed successfully"
msgstr "" msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/index.html.heex:15
#: lib/cannery_web/live/ammo_group_live/index.html.heex:33
msgid "You'll need to"
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.html.heex:67
msgid "Creating..."
msgstr ""
#, elixir-autogen, elixir-format
#: lib/cannery_web/live/ammo_group_live/form_component.ex:134
msgid "Ammo group created successfully"
msgid_plural "Ammo groups created successfully"
msgstr[0] ""
msgstr[1] ""

View File

@ -20,8 +20,8 @@ defmodule Cannery.ActivityLogTest do
container = container_fixture(current_user) container = container_fixture(current_user)
ammo_type = ammo_type_fixture(current_user) ammo_type = ammo_type_fixture(current_user)
{1, [%{id: ammo_group_id} = ammo_group]} = %{id: ammo_group_id} =
ammo_group_fixture(%{"count" => 25}, ammo_type, container, current_user) ammo_group = ammo_group_fixture(%{"count" => 25}, ammo_type, container, current_user)
shot_group = shot_group =
%{"count" => 5, "date" => ~N[2022-02-13 03:17:00], "notes" => "some notes"} %{"count" => 5, "date" => ~N[2022-02-13 03:17:00], "notes" => "some notes"}

View File

@ -108,7 +108,7 @@ defmodule Cannery.AmmoTest do
current_user = user_fixture() current_user = user_fixture()
ammo_type = ammo_type_fixture(current_user) ammo_type = ammo_type_fixture(current_user)
container = container_fixture(current_user) container = container_fixture(current_user)
{1, [ammo_group]} = ammo_group_fixture(ammo_type, container, current_user) ammo_group = ammo_group_fixture(ammo_type, container, current_user)
[ [
ammo_type: ammo_type, ammo_type: ammo_type,
@ -129,28 +129,28 @@ defmodule Cannery.AmmoTest do
ammo_group |> Repo.preload(:shot_groups) ammo_group |> Repo.preload(:shot_groups)
end end
test "create_ammo_groups/3 with valid data creates a ammo_group", test "create_ammo_group/1 with valid data creates a ammo_group",
%{ %{
ammo_type: ammo_type, ammo_type: ammo_type,
container: container, container: container,
current_user: current_user current_user: current_user
} do } do
assert {:ok, {1, [%AmmoGroup{} = ammo_group]}} = assert {:ok, %AmmoGroup{} = ammo_group} =
@valid_attrs @valid_attrs
|> Map.merge(%{"ammo_type_id" => ammo_type.id, "container_id" => container.id}) |> Map.merge(%{"ammo_type_id" => ammo_type.id, "container_id" => container.id})
|> Ammo.create_ammo_groups(1, current_user) |> Ammo.create_ammo_group(current_user)
assert ammo_group.count == 42 assert ammo_group.count == 42
assert ammo_group.notes == "some notes" assert ammo_group.notes == "some notes"
assert ammo_group.price_paid == 120.5 assert ammo_group.price_paid == 120.5
end end
test "create_ammo_groups/3 with invalid data returns error changeset", test "create_ammo_group/1 with invalid data returns error changeset",
%{ammo_type: ammo_type, container: container, current_user: current_user} do %{ammo_type: ammo_type, container: container, current_user: current_user} do
assert {:error, %Changeset{}} = assert {:error, %Changeset{}} =
@invalid_attrs @invalid_attrs
|> Map.merge(%{"ammo_type_id" => ammo_type.id, "container_id" => container.id}) |> Map.merge(%{"ammo_type_id" => ammo_type.id, "container_id" => container.id})
|> Ammo.create_ammo_groups(1, current_user) |> Ammo.create_ammo_group(current_user)
end end
test "update_ammo_group/2 with valid data updates the ammo_group", test "update_ammo_group/2 with valid data updates the ammo_group",

View File

@ -6,26 +6,18 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
use CanneryWeb.ConnCase use CanneryWeb.ConnCase
import Phoenix.LiveViewTest import Phoenix.LiveViewTest
import CanneryWeb.Gettext import CanneryWeb.Gettext
alias Cannery.{Ammo, Repo} alias Cannery.Repo
@moduletag :ammo_group_live_test @moduletag :ammo_group_live_test
@shot_group_create_attrs %{"ammo_left" => 5, "notes" => "some notes"} @shot_group_create_attrs %{"ammo_left" => 5, "notes" => "some notes"}
@shot_group_update_attrs %{"count" => 5, "notes" => "some updated notes"} @create_attrs %{count: 42, notes: "some notes", price_paid: 120.5}
@create_attrs %{"count" => 42, "notes" => "some notes", "price_paid" => 120.5} @update_attrs %{count: 43, notes: "some updated notes", price_paid: 456.7}
@update_attrs %{"count" => 43, "notes" => "some updated notes", "price_paid" => 456.7}
@ammo_group_create_limit 10_000
# @invalid_attrs %{count: -1, notes: nil, price_paid: nil} # @invalid_attrs %{count: -1, notes: nil, price_paid: nil}
defp create_ammo_group(%{current_user: current_user}) do defp create_ammo_group(%{current_user: current_user}) do
ammo_type = ammo_type_fixture(current_user) ammo_type = ammo_type_fixture(current_user)
container = container_fixture(current_user) container = container_fixture(current_user)
{1, [ammo_group]} = ammo_group_fixture(ammo_type, container, current_user) %{ammo_group: ammo_group_fixture(ammo_type, container, current_user)}
shot_group =
%{"count" => 5, "date" => ~N[2022-02-13 03:17:00], "notes" => "some notes"}
|> shot_group_fixture(current_user, ammo_group)
%{ammo_group: ammo_group, shot_group: shot_group}
end end
describe "Index" do describe "Index" do
@ -39,7 +31,7 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
assert html =~ ammo_group.ammo_type.name assert html =~ ammo_group.ammo_type.name
end end
test "saves a single new ammo_group", %{conn: conn} do test "saves new ammo_group", %{conn: conn} do
{:ok, index_live, _html} = live(conn, Routes.ammo_group_index_path(conn, :index)) {:ok, index_live, _html} = live(conn, Routes.ammo_group_index_path(conn, :index))
assert index_live |> element("a", dgettext("actions", "New Ammo group")) |> render_click() =~ assert index_live |> element("a", dgettext("actions", "New Ammo group")) |> render_click() =~
@ -61,68 +53,6 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
assert html =~ "42" assert html =~ "42"
end end
test "saves multiple new ammo_groups", %{conn: conn, current_user: current_user} do
multiplier = 25
{:ok, index_live, _html} = live(conn, Routes.ammo_group_index_path(conn, :index))
assert index_live |> element("a", dgettext("actions", "New Ammo group")) |> render_click() =~
gettext("New Ammo group")
assert_patch(index_live, Routes.ammo_group_index_path(conn, :new))
# assert index_live
# |> form("#ammo_group-form", ammo_group: @invalid_attrs)
# |> render_change() =~ dgettext("errors", "can't be blank")
{:ok, _, html} =
index_live
|> form("#ammo_group-form",
ammo_group: @create_attrs |> Map.put("multiplier", to_string(multiplier))
)
|> render_submit()
|> follow_redirect(conn, Routes.ammo_group_index_path(conn, :index))
assert html =~ dgettext("prompts", "Ammo groups created successfully")
assert Ammo.list_ammo_groups(current_user) |> Enum.count() == multiplier + 1
end
test "does not save invalid number of new ammo_groups", %{conn: conn} do
{:ok, index_live, _html} = live(conn, Routes.ammo_group_index_path(conn, :index))
assert index_live |> element("a", dgettext("actions", "New Ammo group")) |> render_click() =~
gettext("New Ammo group")
assert_patch(index_live, Routes.ammo_group_index_path(conn, :new))
# assert index_live
# |> form("#ammo_group-form", ammo_group: @invalid_attrs)
# |> render_change() =~ dgettext("errors", "can't be blank")
assert index_live
|> form("#ammo_group-form", ammo_group: @create_attrs |> Map.put("multiplier", "0"))
|> render_submit() =~
dgettext(
"errors",
"Invalid number of copies, must be between 1 and %{max}. Was %{multiplier}",
multiplier: 0,
max: @ammo_group_create_limit
)
assert index_live
|> form("#ammo_group-form",
ammo_group:
@create_attrs |> Map.put("multiplier", to_string(@ammo_group_create_limit + 1))
)
|> render_submit() =~
dgettext(
"errors",
"Invalid number of copies, must be between 1 and %{max}. Was %{multiplier}",
multiplier: @ammo_group_create_limit + 1,
max: @ammo_group_create_limit
)
end
test "saves new shot_group", %{conn: conn, ammo_group: ammo_group} do test "saves new shot_group", %{conn: conn, ammo_group: ammo_group} do
{:ok, index_live, _html} = live(conn, Routes.ammo_group_index_path(conn, :index)) {:ok, index_live, _html} = live(conn, Routes.ammo_group_index_path(conn, :index))
@ -234,40 +164,5 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
assert html =~ dgettext("prompts", "Shots recorded successfully") assert html =~ dgettext("prompts", "Shots recorded successfully")
end end
test "updates shot_group in listing",
%{conn: conn, ammo_group: ammo_group, shot_group: shot_group} do
{:ok, index_live, _html} = live(conn, Routes.ammo_group_show_path(conn, :edit, ammo_group))
assert index_live |> element("[data-qa=\"edit-#{shot_group.id}\"]") |> render_click() =~
gettext("Edit Shot Records")
assert_patch(
index_live,
Routes.ammo_group_show_path(conn, :edit_shot_group, ammo_group, shot_group)
)
# assert index_live
# |> form("#shot_group-form", shot_group: @invalid_attrs)
# |> render_change() =~ dgettext("errors", "is invalid")
{:ok, _, html} =
index_live
|> form("#shot-group-form", shot_group: @shot_group_update_attrs)
|> render_submit()
|> follow_redirect(conn, Routes.ammo_group_show_path(conn, :show, ammo_group))
assert html =~ dgettext("actions", "Shot records updated successfully")
assert html =~ "some updated notes"
end
test "deletes shot_group in listing",
%{conn: conn, ammo_group: ammo_group, shot_group: shot_group} do
{:ok, index_live, _html} =
live(conn, Routes.ammo_group_show_path(conn, :edit_shot_group, ammo_group, shot_group))
assert index_live |> element("[data-qa=\"delete-#{shot_group.id}\"]") |> render_click()
refute has_element?(index_live, "#shot_group-#{shot_group.id}")
end
end end
end end

View File

@ -16,9 +16,7 @@ defmodule CanneryWeb.RangeLiveTest do
defp create_shot_group(%{current_user: current_user}) do defp create_shot_group(%{current_user: current_user}) do
container = container_fixture(%{"staged" => true}, current_user) container = container_fixture(%{"staged" => true}, current_user)
ammo_type = ammo_type_fixture(current_user) ammo_type = ammo_type_fixture(current_user)
ammo_group = ammo_group_fixture(%{"staged" => true}, ammo_type, container, current_user)
{1, [ammo_group]} =
ammo_group_fixture(%{"staged" => true}, ammo_type, container, current_user)
shot_group = shot_group =
%{"count" => 5, "date" => ~N[2022-02-13 03:17:00], "notes" => "some notes"} %{"count" => 5, "date" => ~N[2022-02-13 03:17:00], "notes" => "some notes"}

View File

@ -111,20 +111,10 @@ defmodule Cannery.Fixtures do
@doc """ @doc """
Generate a AmmoGroup Generate a AmmoGroup
""" """
@spec ammo_group_fixture(AmmoType.t(), Container.t(), User.t()) :: @spec ammo_group_fixture(AmmoType.t(), Container.t(), User.t()) :: AmmoGroup.t()
{count :: non_neg_integer(), [AmmoGroup.t()]} @spec ammo_group_fixture(attrs :: map(), AmmoType.t(), Container.t(), User.t()) :: AmmoGroup.t()
@spec ammo_group_fixture(attrs :: map(), AmmoType.t(), Container.t(), User.t()) ::
{count :: non_neg_integer(), [AmmoGroup.t()]}
@spec ammo_group_fixture(
attrs :: map(),
multiplier :: non_neg_integer(),
AmmoType.t(),
Container.t(),
User.t()
) :: {count :: non_neg_integer(), [AmmoGroup.t()]}
def ammo_group_fixture( def ammo_group_fixture(
attrs \\ %{}, attrs \\ %{},
multiplier \\ 1,
%AmmoType{id: ammo_type_id}, %AmmoType{id: ammo_type_id},
%Container{id: container_id}, %Container{id: container_id},
%User{} = user %User{} = user
@ -135,7 +125,7 @@ defmodule Cannery.Fixtures do
"container_id" => container_id, "container_id" => container_id,
"count" => 20 "count" => 20
}) })
|> Ammo.create_ammo_groups(multiplier, user) |> Ammo.create_ammo_group(user)
|> unwrap_ok_tuple() |> unwrap_ok_tuple()
end end