mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
feat(portal): Update Client index page to search all columns (#6377)
Why: * Currently, when searching on the Client index page in the portal, the only field being searched is the Client name. This commit adds the ability to search either the Client name or the Actor name. Closes: #5738
This commit is contained in:
@@ -112,10 +112,31 @@ defmodule Domain.Clients.Client.Query do
|
||||
title: "Name",
|
||||
type: {:string, :websearch},
|
||||
fun: &filter_by_name_fts/2
|
||||
},
|
||||
%Domain.Repo.Filter{
|
||||
name: :client_or_actor_name,
|
||||
title: "Client Name or Actor Name",
|
||||
type: {:string, :websearch},
|
||||
fun: &filter_by_client_or_actor_name/2
|
||||
}
|
||||
]
|
||||
|
||||
def filter_by_name_fts(queryable, name) do
|
||||
{queryable, dynamic([clients: clients], fulltext_search(clients.name, ^name))}
|
||||
end
|
||||
|
||||
def filter_by_client_or_actor_name(queryable, name) do
|
||||
queryable =
|
||||
with_named_binding(queryable, :actor, fn queryable, binding ->
|
||||
join(queryable, :inner, [clients: clients], actor in assoc(clients, ^binding),
|
||||
as: ^binding
|
||||
)
|
||||
end)
|
||||
|
||||
{queryable,
|
||||
dynamic(
|
||||
[clients: clients, actor: actor],
|
||||
fulltext_search(clients.name, ^name) or fulltext_search(actor.name, ^name)
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,6 +31,7 @@ defmodule Web.Actors.Show do
|
||||
|> assign_live_table("clients",
|
||||
query_module: Clients.Client.Query,
|
||||
sortable_fields: [],
|
||||
hide_filters: [:client_or_actor_name],
|
||||
callback: &handle_clients_update!/2
|
||||
)
|
||||
|> assign_live_table("flows",
|
||||
|
||||
@@ -15,6 +15,9 @@ defmodule Web.Clients.Index do
|
||||
sortable_fields: [
|
||||
{:clients, :name}
|
||||
],
|
||||
hide_filters: [
|
||||
:name
|
||||
],
|
||||
callback: &handle_clients_update!/2
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user