fix: treat URL with only custom fields as valid in ?fields= mode
Consider visible custom fields in compute_final_field_selection so that a link with only custom_field_X is not wrongly treated as invalid and reverted to session/global. Add test for URL containing only custom field.
This commit is contained in:
parent
d5df2338a7
commit
10ad32eb6f
2 changed files with 15 additions and 2 deletions
|
|
@ -821,9 +821,10 @@ defmodule MvWeb.MemberLive.Index do
|
||||||
only_url =
|
only_url =
|
||||||
FieldVisibility.selection_from_url_only(url_selection, socket.assigns.all_custom_fields)
|
FieldVisibility.selection_from_url_only(url_selection, socket.assigns.all_custom_fields)
|
||||||
|
|
||||||
visible = FieldVisibility.get_visible_member_fields(only_url)
|
visible_members = FieldVisibility.get_visible_member_fields(only_url)
|
||||||
|
visible_custom = FieldVisibility.get_visible_custom_fields(only_url)
|
||||||
|
|
||||||
if visible == [] do
|
if visible_members == [] and visible_custom == [] do
|
||||||
# URL had only invalid field names; fall back to session + global.
|
# URL had only invalid field names; fall back to session + global.
|
||||||
compute_final_field_selection(false, url_selection, socket)
|
compute_final_field_selection(false, url_selection, socket)
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,18 @@ defmodule MvWeb.MemberLive.IndexFieldVisibilityTest do
|
||||||
assert html =~ "Alice"
|
assert html =~ "Alice"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "URL with only custom field keeps custom field visible (no invalid fallback)", %{
|
||||||
|
conn: conn,
|
||||||
|
custom_field: custom_field
|
||||||
|
} do
|
||||||
|
conn = conn_with_oidc_user(conn)
|
||||||
|
id = custom_field.id
|
||||||
|
{:ok, _view, html} = live(conn, "/members?fields=custom_field_#{id}")
|
||||||
|
|
||||||
|
# Selection must not be treated as invalid; custom field column stays visible
|
||||||
|
assert html =~ "M001" or html =~ custom_field.name
|
||||||
|
end
|
||||||
|
|
||||||
test "handles rapid toggling", %{conn: conn} do
|
test "handles rapid toggling", %{conn: conn} do
|
||||||
conn = conn_with_oidc_user(conn)
|
conn = conn_with_oidc_user(conn)
|
||||||
{:ok, view, _html} = live(conn, "/members")
|
{:ok, view, _html} = live(conn, "/members")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue