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 · 2 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

Copy link
Contributor

This issue has been marked as stale because there was no activity for the past 15 days.

@github-actions github-actions bot added the Stale label Dec 17, 2024
Copy link
Contributor

github-actions bot commented Jan 2, 2025

Closing this because there was no activity for the past 15 days. Feel free to reopen if new information pops up ✌️

@github-actions github-actions bot closed this as completed Jan 2, 2025
@github-project-automation github-project-automation bot moved this to Done in Issues Jan 2, 2025
@Paul-Bob Paul-Bob reopened this Jan 3, 2025
@Paul-Bob Paul-Bob moved this from Done to To Do in Issues Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To Do
Development

No branches or pull requests

2 participants