fix shot record error message

This commit is contained in:
shibao 2023-03-18 01:05:09 -04:00
parent c0441957b6
commit 0b7146ba32
2 changed files with 7 additions and 11 deletions

View File

@ -2,6 +2,7 @@
- Improve accessibility - Improve accessibility
- Code quality improvements - Code quality improvements
- Fix dead link of example bullet abbreviations - Fix dead link of example bullet abbreviations
- Fix inaccurate error message when updating shot records
# v0.8.3 # v0.8.3
- Improve some styles - Improve some styles

View File

@ -115,17 +115,12 @@ defmodule Cannery.ActivityLog.ShotGroup do
new_shot_group_count = changeset |> Changeset.get_field(:count) new_shot_group_count = changeset |> Changeset.get_field(:count)
shot_diff_to_add = new_shot_group_count - count shot_diff_to_add = new_shot_group_count - count
cond do if shot_diff_to_add > ammo_group_count do
shot_diff_to_add > ammo_group_count ->
error = 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) changeset |> Changeset.add_error(:count, error)
else
new_shot_group_count <= 0 ->
changeset |> Changeset.add_error(:count, dgettext("errors", "Count must be at least 1"))
true ->
changeset changeset
end end
end end