fix shot record error message
This commit is contained in:
parent
c0441957b6
commit
0b7146ba32
@ -2,6 +2,7 @@
|
||||
- Improve accessibility
|
||||
- Code quality improvements
|
||||
- Fix dead link of example bullet abbreviations
|
||||
- Fix inaccurate error message when updating shot records
|
||||
|
||||
# v0.8.3
|
||||
- Improve some styles
|
||||
|
@ -115,17 +115,12 @@ defmodule Cannery.ActivityLog.ShotGroup do
|
||||
new_shot_group_count = changeset |> Changeset.get_field(:count)
|
||||
shot_diff_to_add = new_shot_group_count - count
|
||||
|
||||
cond do
|
||||
shot_diff_to_add > ammo_group_count ->
|
||||
if shot_diff_to_add > ammo_group_count do
|
||||
error =
|
||||
dgettext("errors", "Count must be less than %{count} shots", count: ammo_group_count)
|
||||
dgettext("errors", "Count can be at most %{count} shots", count: ammo_group_count + count)
|
||||
|
||||
changeset |> Changeset.add_error(:count, error)
|
||||
|
||||
new_shot_group_count <= 0 ->
|
||||
changeset |> Changeset.add_error(:count, dgettext("errors", "Count must be at least 1"))
|
||||
|
||||
true ->
|
||||
else
|
||||
changeset
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user