From ee28de11787819d3f93dde7d2b9f99f42d6c3f56 Mon Sep 17 00:00:00 2001 From: shibao Date: Wed, 23 Feb 2022 19:41:21 -0500 Subject: [PATCH] fix not showing 0 if ammo type with 0 rounds --- lib/cannery/ammo.ex | 4 ++-- lib/cannery_web/live/ammo_type_live/show.html.heex | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/cannery/ammo.ex b/lib/cannery/ammo.ex index 67c145b..186cdd8 100644 --- a/lib/cannery/ammo.ex +++ b/lib/cannery/ammo.ex @@ -90,7 +90,7 @@ defmodule Cannery.Ammo do from ag in AmmoGroup, where: ag.ammo_type_id == ^ammo_type_id, select: sum(ag.count) - ) + ) || 0 end @doc """ @@ -117,7 +117,7 @@ defmodule Cannery.Ammo do left_join: sg in assoc(ag, :shot_groups), where: ag.ammo_type_id == ^ammo_type_id, select: sum(sg.count) - ) + ) || 0 end @doc """ diff --git a/lib/cannery_web/live/ammo_type_live/show.html.heex b/lib/cannery_web/live/ammo_type_live/show.html.heex index 1ad98f8..f881163 100644 --- a/lib/cannery_web/live/ammo_type_live/show.html.heex +++ b/lib/cannery_web/live/ammo_type_live/show.html.heex @@ -100,9 +100,8 @@ ) %> <% else %> -

+

<%= gettext("No cost information") %> - <%= display_emoji("😔") %>

<% end %> @@ -111,8 +110,10 @@
<%= if @ammo_groups |> Enum.empty?() do %> - <%= gettext("No ammo for this type") %> - <%= display_emoji("😔") %> +

+ <%= gettext("No ammo for this type") %> + <%= display_emoji("😔") %> +

<% else %>
<%= for ammo_group <- @ammo_groups do %>