remove default boolean columns if all false
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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 %> | ||||
|       <div class="flex flex-wrap justify-center items-center"> | ||||
|         <%= for ammo_group <- @ammo_groups do %> | ||||
|           <.ammo_group_card ammo_group={ammo_group} /> | ||||
|         <% end %> | ||||
|       </div> | ||||
|     <% end %> | ||||
|   </div> | ||||
| </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user