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:
Brian Manifold
2024-08-26 14:57:41 -07:00
committed by GitHub
parent 43dc6c2053
commit 5d3fc7d0c4
3 changed files with 25 additions and 0 deletions

View File

@@ -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

View File

@@ -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",

View File

@@ -15,6 +15,9 @@ defmodule Web.Clients.Index do
sortable_fields: [
{:clients, :name}
],
hide_filters: [
:name
],
callback: &handle_clients_update!/2
)