From 43c8d8d910c65f36ef480fb288cf8740b6ed9a2b Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Mon, 30 Sep 2024 11:02:13 -0400 Subject: [PATCH] fix: properly include calc args in `to_filter_map` --- lib/ash_phoenix/filter_form/filter_form.ex | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/ash_phoenix/filter_form/filter_form.ex b/lib/ash_phoenix/filter_form/filter_form.ex index 9879b70..fe673f6 100644 --- a/lib/ash_phoenix/filter_form/filter_form.ex +++ b/lib/ash_phoenix/filter_form/filter_form.ex @@ -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}} @@ -577,9 +584,6 @@ defmodule AshPhoenix.FilterForm do resource: Ash.Resource.Info.related(resource, path), input?: true }} - else - {:error, error} -> - {:error, error} end end