diff --git a/CHANGELOG.md b/CHANGELOG.md index 2983e28..c7627c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Add or remove tags from Containers list and details page - Show tags on containers - Add "Cannery" to page titles +- Don't show true/false column for ammo types if all values are false # 0.1.0 diff --git a/lib/cannery_web/live/ammo_type_live/index.ex b/lib/cannery_web/live/ammo_type_live/index.ex index e506db3..52b3a86 100644 --- a/lib/cannery_web/live/ammo_type_live/index.ex +++ b/lib/cannery_web/live/ammo_type_live/index.ex @@ -73,6 +73,14 @@ defmodule CanneryWeb.AmmoTypeLive.Index do |> Enum.filter(fn {_label, field, _type} -> ammo_types |> Enum.any?(fn ammo_type -> not (ammo_type |> Map.get(field) |> is_nil()) end) end) + # if boolean, remove if all values are false + |> Enum.filter(fn {_label, field, type} -> + if type == :boolean do + ammo_types |> Enum.any?(fn ammo_type -> not (ammo_type |> Map.get(field) == false) end) + else + true + end + end) socket |> assign(ammo_types: ammo_types, columns_to_display: columns_to_display) end 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 d86d8d1..b4b2934 100644 --- a/lib/cannery_web/live/ammo_type_live/show.html.heex +++ b/lib/cannery_web/live/ammo_type_live/show.html.heex @@ -108,9 +108,11 @@ <%= if @ammo_groups |> Enum.empty?() do %> <%= gettext("No ammo for this type") %> <% else %> - <%= for ammo_group <- @ammo_groups do %> - <.ammo_group_card ammo_group={ammo_group} /> - <% end %> +
+ <%= for ammo_group <- @ammo_groups do %> + <.ammo_group_card ammo_group={ammo_group} /> + <% end %> +
<% end %>