Skip to content

Commit da7469c

Browse files
committed
feat: add apply search query method to search resource items
1 parent 5c0798e commit da7469c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/controllers/avo/base_controller.rb

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def index
2525
end
2626
add_breadcrumb @resource.plural_name.humanize
2727

28+
# Apply the search query if configured on the resource
29+
apply_search_query if params[:q].present? && @resource.search.present?
2830
set_index_params
2931
set_filters
3032
set_actions
@@ -658,5 +660,12 @@ def set_pagination_params
658660
def set_query
659661
@query ||= @resource.class.query_scope
660662
end
663+
664+
def apply_search_query
665+
search_query = @resource.search[:query]
666+
return unless search_query.present?
667+
668+
@query = instance_exec(@query, &search_query)
669+
end
661670
end
662671
end

0 commit comments

Comments
 (0)