fix shot record error message
This commit is contained in:
parent
c0441957b6
commit
0b7146ba32
@ -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
|
||||||
|
@ -115,18 +115,13 @@ 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 can be at most %{count} shots", count: ammo_group_count + count)
|
||||||
dgettext("errors", "Count must be less than %{count} shots", count: ammo_group_count)
|
|
||||||
|
|
||||||
changeset |> Changeset.add_error(:count, error)
|
changeset |> Changeset.add_error(:count, error)
|
||||||
|
else
|
||||||
new_shot_group_count <= 0 ->
|
changeset
|
||||||
changeset |> Changeset.add_error(:count, dgettext("errors", "Count must be at least 1"))
|
|
||||||
|
|
||||||
true ->
|
|
||||||
changeset
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user