fix(members): restore column visibility from URL on reload
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Read 'fields' from URI when conn.params has no query (e.g. full page load). When ?fields=... is present use URL-only selection so columns are not merged with global settings. Fall back to session+global when URL has only invalid field names.
This commit is contained in:
parent
e86c78a0dc
commit
d41d13d122
2 changed files with 86 additions and 15 deletions
|
|
@ -64,6 +64,25 @@ defmodule MvWeb.MemberLive.Index.FieldVisibility do
|
|||
member_fields ++ custom_field_names
|
||||
end
|
||||
|
||||
@doc """
|
||||
Builds field selection from URL only: fields in `url_selection` are visible, all others false.
|
||||
Use when `?fields=...` is in the URL so column visibility is not merged with global settings.
|
||||
"""
|
||||
@spec selection_from_url_only(%{String.t() => boolean()}, [struct()]) :: %{
|
||||
String.t() => boolean()
|
||||
}
|
||||
def selection_from_url_only(url_selection, custom_fields) when is_map(url_selection) do
|
||||
all_fields = get_all_available_fields(custom_fields)
|
||||
|
||||
Enum.reduce(all_fields, %{}, fn field, acc ->
|
||||
field_string = field_to_string(field)
|
||||
visible = Map.get(url_selection, field_string, false)
|
||||
Map.put(acc, field_string, visible)
|
||||
end)
|
||||
end
|
||||
|
||||
def selection_from_url_only(_, _), do: %{}
|
||||
|
||||
@doc """
|
||||
Merges user field selection with global settings.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue