Support binary_id search fields
Thank you for the great job with this library!
Right now https://github.com/mojotech/torch/blob/facc69fef8ef34fa27862e5d62f09e6d8c46ce8e/lib/torch/views/filter_view.ex works great with almost all type of data structures, the only problem I found is when adding a filter search for a binary_id, it should only support "equals" as lower(binary_id) is not supported (by postgres)
I could send a PR, I have an idea of how to implement it. Shall I proceed?
I would add something like the following to lib/torch/views/filter_view.ex:
@doc """
Generates a "equals" filter type select box for a given `uuid` field
## Example
iex> params = %{"post" => %{"id_equals" => "test"}}
...> filter_uuid(:post, :id, params) |> safe_to_string()
"<select class=\\"filter-type\\" id=\\"filters_\\" name=\\"filters[]\\"><option value=\\"post[id_equals]\\">Equals</option></select>"
"""
@spec filter_uuid(prefix, field, map) :: Phoenix.HTML.safe()
def filter_uuid(prefix, field, params) do
prefix_str = to_string(prefix)
{selected, _value} = find_param(params[prefix_str], field, :select)
opts = [
{message("Equals"), "#{prefix}[#{field}_equals]"}
]
select(:filters, "", opts, class: "filter-type", value: "#{prefix}[#{selected}]")
end
@lorenzosinisi We'd love to have you submit a PR for this if possible. If you feel you have a path for a solution we'd love to get a PR from you with a corresponding test case (if possible) for regressions in the future.
@lorenzosinisi Just following up on this issue. Is this something you are still working and submitting a Pull Request for or can/should we close this issue?
@lorenzosinisi Just following up one more time on this as it's been about 2 months with no more feedback. If you are still interested in doing this work, please let me know and we can keep this issue open, otherwise I will close it soon due to no activity, thanks.