Implement dropdown to show/hide columns in member overview closes #209 #240

Merged
moritz merged 28 commits from feature/209_hide_field_dropdown into main 2025-12-03 19:01:15 +01:00
2 changed files with 11 additions and 12 deletions
Showing only changes of commit 690083bdf0 - Show all commits

View file

@ -153,20 +153,20 @@ defmodule MvWeb.Components.FieldVisibilityDropdownComponent do
|> field_to_string()
|> String.replace("_", " ")
|> String.split()
|> Enum.map(&String.capitalize/1)
|> Enum.join(" ")
|> Enum.map_join(" ", &String.capitalize/1)
end
defp format_custom_field_label(field_string, custom_fields) do
case String.trim_leading(field_string, "custom_field_") do
"" ->
field_string
id = String.trim_leading(field_string, "custom_field_")
find_custom_field_name(id, field_string, custom_fields)
end
id ->
case Enum.find(custom_fields, fn cf -> to_string(cf.id) == id end) do
nil -> gettext("Custom Field %{id}", id: id)
custom_field -> custom_field.name
end
defp find_custom_field_name("", field_string, _custom_fields), do: field_string
defp find_custom_field_name(id, _field_string, custom_fields) do
case Enum.find(custom_fields, fn cf -> to_string(cf.id) == id end) do
nil -> gettext("Custom Field %{id}", id: id)
custom_field -> custom_field.name
end
end
end

View file

@ -198,8 +198,7 @@ defmodule MvWeb.MemberLive.Index.FieldSelection do
def to_url_param(selection) when is_map(selection) do
selection
|> Enum.filter(fn {_field, visible} -> visible end)
|> Enum.map(fn {field, _visible} -> field end)
|> Enum.join(",")
|> Enum.map_join(",", fn {field, _visible} -> field end)
end
def to_url_param(_), do: ""