fix: implement review comments
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
65581d0639
commit
ace59bbae6
7 changed files with 43 additions and 37 deletions
|
|
@ -977,6 +977,7 @@ defmodule MvWeb.MemberLive.Index do
|
|||
end
|
||||
end
|
||||
|
||||
# Multiple group filters combine with AND: member must match all selected group conditions.
|
||||
defp apply_group_filters(query, group_filters, _groups) when group_filters == %{}, do: query
|
||||
|
||||
defp apply_group_filters(query, group_filters, groups) do
|
||||
|
|
@ -1103,9 +1104,10 @@ defmodule MvWeb.MemberLive.Index do
|
|||
end
|
||||
|
||||
defp valid_sort_field_db_or_custom?(field) when is_binary(field) do
|
||||
field == "groups" or
|
||||
custom_field_sort?(field) or
|
||||
((atom = safe_member_field_atom_only(field)) != nil and valid_sort_field_db_or_custom?(atom))
|
||||
normalized = if field == "groups", do: :groups, else: safe_member_field_atom_only(field)
|
||||
|
||||
(normalized != nil and valid_sort_field_db_or_custom?(normalized)) or
|
||||
custom_field_sort?(field)
|
||||
end
|
||||
|
||||
defp safe_member_field_atom_only(str) do
|
||||
|
|
@ -1161,11 +1163,11 @@ defmodule MvWeb.MemberLive.Index do
|
|||
end
|
||||
|
||||
defp sort_members_by_groups(members, order) do
|
||||
# Members with groups first, then by first group name alphabetically
|
||||
# Members with groups first, then by first group name alphabetically (min = first by sort order)
|
||||
first_group_name = fn member ->
|
||||
groups = member.groups || []
|
||||
names = Enum.map(groups, & &1.name) |> Enum.sort()
|
||||
List.first(names)
|
||||
(member.groups || [])
|
||||
|> Enum.map(& &1.name)
|
||||
|> Enum.min(fn -> nil end)
|
||||
end
|
||||
|
||||
members
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue