Skip to content

Commit

Permalink
Add search_results_count to configuration (#2898)
Browse files Browse the repository at this point in the history
  • Loading branch information
binarygit authored Jun 28, 2024
1 parent 8436b09 commit cc5190c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/avo/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def search_resource(resource)
results_count = query.reselect(resource.model_class.primary_key).count

# Get the results
query = query.limit(8)
query = query.limit(Avo.configuration.search_results_count)

results = apply_search_metadata(query, resource)

Expand Down
2 changes: 2 additions & 0 deletions lib/avo/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Configuration
attr_accessor :default_url_options
attr_accessor :click_row_to_view_record
attr_accessor :alert_dismiss_time
attr_accessor :search_results_count

def initialize
@root_path = "/avo"
Expand Down Expand Up @@ -109,6 +110,7 @@ def initialize
@pagination = {}
@click_row_to_view_record = false
@alert_dismiss_time = 5000
@search_results_count = 8
end

def current_user_method(&block)
Expand Down
4 changes: 4 additions & 0 deletions lib/generators/avo/templates/initializer/avo.tt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ Avo.configure do |config|
## == Response messages dismiss time ==
# config.alert_dismiss_time = 5000


## == Number of search results to display ==
# config.search_results_count = 8

## == Cache options ==
## Provide a lambda to customize the cache store used by Avo.
## We compute the cache store by default, this is NOT the default, just an example.
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/config/initializers/avo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
# ]

config.alert_dismiss_time = 5000
config.search_results_count = 8

## == Menus ==
config.main_menu = -> do
Expand Down

0 comments on commit cc5190c

Please sign in to comment.