Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support binary_id search fields #256

Open
lorenzosinisi opened this issue Aug 13, 2021 · 3 comments
Open

Support binary_id search fields #256

lorenzosinisi opened this issue Aug 13, 2021 · 3 comments

Comments

@lorenzosinisi
Copy link

lorenzosinisi commented Aug 13, 2021

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
@cpjolicoeur
Copy link
Member

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

@cpjolicoeur
Copy link
Member

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

@cpjolicoeur
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants