remove default boolean columns if all false
This commit is contained in:
		| @@ -2,6 +2,7 @@ | |||||||
| - Add or remove tags from Containers list and details page | - Add or remove tags from Containers list and details page | ||||||
| - Show tags on containers | - Show tags on containers | ||||||
| - Add "Cannery" to page titles | - Add "Cannery" to page titles | ||||||
|  | - Don't show true/false column for ammo types if all values are false | ||||||
|  |  | ||||||
|  |  | ||||||
| # 0.1.0 | # 0.1.0 | ||||||
|   | |||||||
| @@ -73,6 +73,14 @@ defmodule CanneryWeb.AmmoTypeLive.Index do | |||||||
|       |> Enum.filter(fn {_label, field, _type} -> |       |> Enum.filter(fn {_label, field, _type} -> | ||||||
|         ammo_types |> Enum.any?(fn ammo_type -> not (ammo_type |> Map.get(field) |> is_nil()) end) |         ammo_types |> Enum.any?(fn ammo_type -> not (ammo_type |> Map.get(field) |> is_nil()) end) | ||||||
|       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) |     socket |> assign(ammo_types: ammo_types, columns_to_display: columns_to_display) | ||||||
|   end |   end | ||||||
|   | |||||||
| @@ -108,9 +108,11 @@ | |||||||
|     <%= if @ammo_groups |> Enum.empty?() do %> |     <%= if @ammo_groups |> Enum.empty?() do %> | ||||||
|       <%= gettext("No ammo for this type") %> |       <%= gettext("No ammo for this type") %> | ||||||
|     <% else %> |     <% else %> | ||||||
|       <%= for ammo_group <- @ammo_groups do %> |       <div class="flex flex-wrap justify-center items-center"> | ||||||
|         <.ammo_group_card ammo_group={ammo_group} /> |         <%= for ammo_group <- @ammo_groups do %> | ||||||
|       <% end %> |           <.ammo_group_card ammo_group={ammo_group} /> | ||||||
|  |         <% end %> | ||||||
|  |       </div> | ||||||
|     <% end %> |     <% end %> | ||||||
|   </div> |   </div> | ||||||
| </div> | </div> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user