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

feature: mark highlight search #2370

Merged
merged 7 commits into from
Jan 17, 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
6 changes: 3 additions & 3 deletions app/controllers/avo/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Avo
class SearchController < ApplicationController
include Rails.application.routes.url_helpers
include ActionView::Helpers::TextHelper

before_action :set_resource_name, only: :show
before_action :set_resource, only: :show
Expand Down Expand Up @@ -121,12 +122,11 @@ def apply_search_metadata(records, avo_resource)
end
end

private
gabrielgiroe1 marked this conversation as resolved.
Show resolved Hide resolved

def fetch_result_information(record, resource, item)
highlighted_title = highlight(item&.dig(:title) || resource.record_title, params[:q])
{
_id: record.id,
_label: item&.dig(:title) || resource.record_title,
_label: highlighted_title,
_url: resource.class.fetch_search(:result_path, record: resource.record) || resource.record_path
}
end
Expand Down