From 329713089099607c7dd1c9b3788dd4fe8a785c07 Mon Sep 17 00:00:00 2001 From: shibao Date: Tue, 19 Apr 2022 19:38:03 -0400 Subject: [PATCH] Fix not being able to edit ammo group when fully used up --- CHANGELOG.md | 1 + lib/cannery/ammo/ammo_group.ex | 2 +- lib/cannery_web/live/ammo_group_live/form_component.html.heex | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dfc7c2e..bab82467 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # v0.5.0 - Add German translation: Thank you [Kaia](https://shitposter.club/users/kaia)! +- Fix not being able to edit ammo group when fully used up # v0.4.1 - Fix button and tag text wrapping diff --git a/lib/cannery/ammo/ammo_group.ex b/lib/cannery/ammo/ammo_group.ex index 97231aed..9e9954b1 100644 --- a/lib/cannery/ammo/ammo_group.ex +++ b/lib/cannery/ammo/ammo_group.ex @@ -62,7 +62,7 @@ defmodule Cannery.Ammo.AmmoGroup do def update_changeset(ammo_group, attrs) do ammo_group |> cast(attrs, [:count, :price_paid, :notes, :staged, :ammo_type_id, :container_id]) - |> validate_number(:count, greater_than: 0) + |> validate_number(:count, greater_than_or_equal_to: 0) |> validate_required([:count, :staged, :ammo_type_id, :container_id, :user_id]) end diff --git a/lib/cannery_web/live/ammo_group_live/form_component.html.heex b/lib/cannery_web/live/ammo_group_live/form_component.html.heex index 3fe8bf2d..45afcdcf 100644 --- a/lib/cannery_web/live/ammo_group_live/form_component.html.heex +++ b/lib/cannery_web/live/ammo_group_live/form_component.html.heex @@ -27,7 +27,7 @@ <%= label(f, :count, gettext("Count"), class: "title text-lg text-primary-600") %> <%= number_input(f, :count, class: "text-center col-span-2 input input-primary", - min: 1 + min: 0 ) %> <%= error_tag(f, :count, "col-span-3 text-center") %>