Skip to content

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

Open
@pjmuller

Description

@pjmuller

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions