forked from shibao/cannery
rename ammo groups to packs everywhere
This commit is contained in:
@ -4,7 +4,7 @@ defmodule Cannery.ActivityLog do
|
||||
"""
|
||||
|
||||
import Ecto.Query, warn: false
|
||||
alias Cannery.Ammo.{Pack, AmmoType}
|
||||
alias Cannery.Ammo.{AmmoType, Pack}
|
||||
alias Cannery.{Accounts.User, ActivityLog.ShotGroup, Repo}
|
||||
alias Ecto.{Multi, Queryable}
|
||||
|
||||
@ -269,7 +269,7 @@ defmodule Cannery.ActivityLog do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns the number of shot rounds for an ammo group
|
||||
Returns the number of shot rounds for a pack
|
||||
"""
|
||||
@spec get_used_count(Pack.t(), User.t()) :: non_neg_integer()
|
||||
def get_used_count(%Pack{id: pack_id} = pack, user) do
|
||||
@ -279,7 +279,7 @@ defmodule Cannery.ActivityLog do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns the number of shot rounds for multiple ammo groups
|
||||
Returns the number of shot rounds for multiple packs
|
||||
"""
|
||||
@spec get_used_counts([Pack.t()], User.t()) ::
|
||||
%{optional(Pack.id()) => non_neg_integer()}
|
||||
@ -299,7 +299,7 @@ defmodule Cannery.ActivityLog do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns the last entered shot group date for an ammo group
|
||||
Returns the last entered shot group date for a pack
|
||||
"""
|
||||
@spec get_last_used_date(Pack.t(), User.t()) :: Date.t() | nil
|
||||
def get_last_used_date(%Pack{id: pack_id} = pack, user) do
|
||||
@ -309,7 +309,7 @@ defmodule Cannery.ActivityLog do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns the last entered shot group date for an ammo group
|
||||
Returns the last entered shot group date for a pack
|
||||
"""
|
||||
@spec get_last_used_dates([Pack.t()], User.t()) :: %{optional(Pack.id()) => Date.t()}
|
||||
def get_last_used_dates(packs, %User{id: user_id}) do
|
||||
|
@ -8,7 +8,7 @@ defmodule Cannery.Ammo do
|
||||
alias Cannery.{Accounts.User, Containers, Repo}
|
||||
alias Cannery.Containers.{Container, ContainerTag, Tag}
|
||||
alias Cannery.{ActivityLog, ActivityLog.ShotGroup}
|
||||
alias Cannery.Ammo.{Pack, AmmoType}
|
||||
alias Cannery.Ammo.{AmmoType, Pack}
|
||||
alias Ecto.{Changeset, Queryable}
|
||||
|
||||
@pack_create_limit 10_000
|
||||
@ -128,7 +128,7 @@ defmodule Cannery.Ammo do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets the average cost of an ammo type from ammo groups with price information.
|
||||
Gets the average cost of an ammo type from packs with price information.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -147,7 +147,7 @@ defmodule Cannery.Ammo do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets the average cost of ammo types from ammo groups with price information
|
||||
Gets the average cost of ammo types from packs with price information
|
||||
for multiple ammo types.
|
||||
|
||||
## Examples
|
||||
@ -745,7 +745,7 @@ defmodule Cannery.Ammo do
|
||||
[%Pack{}, ...]
|
||||
|
||||
iex> list_packs("cool", %User{id: 123}, true)
|
||||
[%Pack{notes: "My cool ammo group"}, ...]
|
||||
[%Pack{notes: "My cool pack"}, ...]
|
||||
|
||||
"""
|
||||
@spec list_packs(search :: String.t() | nil, AmmoType.class() | :all, User.t()) ::
|
||||
@ -864,7 +864,7 @@ defmodule Cannery.Ammo do
|
||||
@doc """
|
||||
Gets a single pack.
|
||||
|
||||
Raises `KeyError` if the Ammo group does not exist.
|
||||
Raises `KeyError` if the pack does not exist.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -903,7 +903,7 @@ defmodule Cannery.Ammo do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Calculates the percentage remaining of an ammo group out of 100
|
||||
Calculates the percentage remaining of a pack out of 100
|
||||
|
||||
## Examples
|
||||
|
||||
@ -922,7 +922,7 @@ defmodule Cannery.Ammo do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Calculates the percentages remaining of multiple ammo groups out of 100
|
||||
Calculates the percentages remaining of multiple packs out of 100
|
||||
|
||||
## Examples
|
||||
|
||||
@ -951,7 +951,7 @@ defmodule Cannery.Ammo do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets the original count for an ammo group
|
||||
Gets the original count for a pack
|
||||
|
||||
## Examples
|
||||
|
||||
@ -970,7 +970,7 @@ defmodule Cannery.Ammo do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets the original counts for multiple ammo groups
|
||||
Gets the original counts for multiple packs
|
||||
|
||||
## Examples
|
||||
|
||||
@ -993,7 +993,7 @@ defmodule Cannery.Ammo do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Calculates the CPR for a single ammo group
|
||||
Calculates the CPR for a single pack
|
||||
|
||||
## Examples
|
||||
|
||||
@ -1012,7 +1012,7 @@ defmodule Cannery.Ammo do
|
||||
end
|
||||
|
||||
@doc """
|
||||
Calculates the CPR for multiple ammo groups
|
||||
Calculates the CPR for multiple packs
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -113,7 +113,7 @@ defmodule Cannery.Ammo.Pack do
|
||||
end
|
||||
|
||||
@doc """
|
||||
This range changeset is used when "using up" ammo groups, and allows for
|
||||
This range changeset is used when "using up" packs, and allows for
|
||||
updating the count to 0
|
||||
"""
|
||||
@spec range_changeset(t() | new_pack(), attrs :: map()) :: changeset()
|
||||
|
@ -1,6 +1,6 @@
|
||||
defmodule CanneryWeb.Components.MovePackComponent do
|
||||
@moduledoc """
|
||||
Livecomponent that can move an ammo group to another container
|
||||
Livecomponent that can move a pack to another container
|
||||
"""
|
||||
|
||||
use CanneryWeb, :live_component
|
||||
|
@ -1,6 +1,6 @@
|
||||
defmodule CanneryWeb.Components.PackTableComponent do
|
||||
@moduledoc """
|
||||
A component that displays a list of ammo groups
|
||||
A component that displays a list of packs
|
||||
"""
|
||||
use CanneryWeb, :live_component
|
||||
alias Cannery.{Accounts.User, Ammo.Pack, ComparableDate}
|
||||
|
@ -203,9 +203,7 @@
|
||||
navigate={Routes.pack_show_path(Endpoint, :show, pack)}
|
||||
class="text-primary-600 link"
|
||||
aria-label={
|
||||
dgettext("actions", "View ammo group of %{pack_count} bullets",
|
||||
pack_count: pack_count
|
||||
)
|
||||
dgettext("actions", "View pack of %{pack_count} bullets", pack_count: pack_count)
|
||||
}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-eye"></i>
|
||||
|
@ -4,7 +4,7 @@ defmodule CanneryWeb.PackLive.FormComponent do
|
||||
"""
|
||||
|
||||
use CanneryWeb, :live_component
|
||||
alias Cannery.Ammo.{Pack, AmmoType}
|
||||
alias Cannery.Ammo.{AmmoType, Pack}
|
||||
alias Cannery.{Accounts.User, Ammo, Containers, Containers.Container}
|
||||
alias Ecto.Changeset
|
||||
alias Phoenix.LiveView.Socket
|
||||
|
@ -148,7 +148,7 @@ defmodule CanneryWeb.PackLive.Index do
|
||||
}
|
||||
} = socket
|
||||
) do
|
||||
# get total number of ammo groups to determine whether to display onboarding
|
||||
# get total number of packs to determine whether to display onboarding
|
||||
# prompts
|
||||
packs_count = Ammo.get_packs_count!(current_user, true)
|
||||
packs = Ammo.list_packs(search, class, current_user, show_used)
|
||||
|
@ -151,9 +151,7 @@
|
||||
navigate={Routes.pack_show_path(Endpoint, :show, pack)}
|
||||
class="text-primary-600 link"
|
||||
aria-label={
|
||||
dgettext("actions", "View ammo group of %{pack_count} bullets",
|
||||
pack_count: pack_count
|
||||
)
|
||||
dgettext("actions", "View pack of %{pack_count} bullets", pack_count: pack_count)
|
||||
}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-eye"></i>
|
||||
@ -163,9 +161,7 @@
|
||||
patch={Routes.pack_index_path(Endpoint, :edit, pack)}
|
||||
class="text-primary-600 link"
|
||||
aria-label={
|
||||
dgettext("actions", "Edit ammo group of %{pack_count} bullets",
|
||||
pack_count: pack_count
|
||||
)
|
||||
dgettext("actions", "Edit pack of %{pack_count} bullets", pack_count: pack_count)
|
||||
}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
@ -175,7 +171,7 @@
|
||||
patch={Routes.pack_index_path(Endpoint, :clone, pack)}
|
||||
class="text-primary-600 link"
|
||||
aria-label={
|
||||
dgettext("actions", "Clone ammo group of %{pack_count} bullets",
|
||||
dgettext("actions", "Clone pack of %{pack_count} bullets",
|
||||
pack_count: pack_count
|
||||
)
|
||||
}
|
||||
@ -190,7 +186,7 @@
|
||||
phx-value-id={pack.id}
|
||||
data-confirm={dgettext("prompts", "Are you sure you want to delete this ammo?")}
|
||||
aria-label={
|
||||
dgettext("actions", "Delete ammo group of %{pack_count} bullets",
|
||||
dgettext("actions", "Delete pack of %{pack_count} bullets",
|
||||
pack_count: pack_count
|
||||
)
|
||||
}
|
||||
|
@ -59,7 +59,7 @@
|
||||
patch={Routes.pack_show_path(Endpoint, :edit, @pack)}
|
||||
class="mx-4 my-2 text-primary-600 link"
|
||||
aria-label={
|
||||
dgettext("actions", "Edit ammo group of %{pack_count} bullets", pack_count: @pack.count)
|
||||
dgettext("actions", "Edit pack of %{pack_count} bullets", pack_count: @pack.count)
|
||||
}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
@ -71,9 +71,7 @@
|
||||
phx-click="delete"
|
||||
data-confirm={dgettext("prompts", "Are you sure you want to delete this ammo?")}
|
||||
aria-label={
|
||||
dgettext("actions", "Delete ammo group of %{pack_count} bullets",
|
||||
pack_count: @pack.count
|
||||
)
|
||||
dgettext("actions", "Delete pack of %{pack_count} bullets", pack_count: @pack.count)
|
||||
}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
|
Reference in New Issue
Block a user