Skip to content

Commit

Permalink
fix: properly include calc args in to_filter_map
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Sep 30, 2024
1 parent 9d5d7bd commit 43c8d8d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/ash_phoenix/filter_form/filter_form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,21 @@ defmodule AshPhoenix.FilterForm do
value: value,
operator: operator,
negated?: negated?,
arguments: arguments,
path: path
},
_resource
) do
expr =
put_at_path(%{}, Enum.map(path, &to_string/1), %{
to_string(field) => %{to_string(operator) => value}
})
if arguments && arguments.input not in [nil, %{}] do
put_at_path(%{}, Enum.map(path, &to_string/1), %{
to_string(field) => %{to_string(operator) => value, "input" => arguments.input}
})
else
put_at_path(%{}, Enum.map(path, &to_string/1), %{
to_string(field) => %{to_string(operator) => value}
})
end

if negated? do
{:ok, %{"not" => expr}}
Expand Down Expand Up @@ -577,9 +584,6 @@ defmodule AshPhoenix.FilterForm do
resource: Ash.Resource.Info.related(resource, path),
input?: true
}}
else
{:error, error} ->
{:error, error}
end
end

Expand Down

0 comments on commit 43c8d8d

Please sign in to comment.