Skip to content

Commit

Permalink
feat: add apply search query method to search resource items
Browse files Browse the repository at this point in the history
  • Loading branch information
SahSantoshh committed Jan 29, 2025
1 parent 8c7331b commit 3fb4517
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/controllers/avo/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def index
end
add_breadcrumb @resource.plural_name.humanize

# Apply the search query if configured on the resource
apply_search_query if params[:q].present? && @resource.search.present?
set_index_params
set_filters
set_actions
Expand Down Expand Up @@ -643,5 +645,12 @@ def set_pagination_params
def set_query
@query ||= @resource.class.query_scope
end

def apply_search_query
search_query = @resource.search[:query]
return unless search_query.present?

@query = instance_exec(@query, &search_query)
end
end
end

0 comments on commit 3fb4517

Please sign in to comment.