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

fix: search when link_to_child_resource #2635

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/controllers/avo/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,16 @@ def fetch_result_information(record, resource, item)
title = item&.dig(:title) || resource.record_title
highlighted_title = highlight(title&.to_s, params[:q])

record_path = if resource.link_to_child_resource
Avo.resource_manager.get_resource_by_model_class(record.class).new(record: record).record_path
else
resource.record_path
end

{
_id: record.id,
_label: highlighted_title,
_url: resource.class.fetch_search(:result_path, record: resource.record) || resource.record_path
_url: resource.class.fetch_search(:result_path, record: resource.record) || record_path
}
end

Expand Down