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

search within association should append the ?via_record_id=xxx&via_resource_class=yyy #3474

Open
pjmuller opened this issue Dec 1, 2024 · 0 comments

Comments

@pjmuller
Copy link

pjmuller commented Dec 1, 2024

Feature

When you use the search within an association as

field :columns, as: :has_many,
                        hide_search_input: false # 👈

and click the result than you lose the association where you came from

Current workarounds

Hardcode the results, but that feels dirty

 self.search = {
        results_count: 40,
        query: -> {
          if params['via_reflection_class'] == 'Table'
            table_id = params['via_reflection_id']
            return query.where(avo_table_id: table_id)
                        .where('label ILIKE ?', "%#{params[:q]}%")
                        .pluck(:id, :label)
                        .map do |id, label|
              {
                _id: id,
                _label: label,
                _url: "/avo/resources/table_columns/#{id}?via_record_id=#{params['via_reflection_id']}&via_resource_class=Avo::Resources::Table"
              }
            end
          end

Additional context

The breadcrumb is such a nice feature to stay in context of where you were working, but without the monkey patch above you would lose it

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

No branches or pull requests

1 participant