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

Backport #2657: Extract default pagination options to engine-level configuration #2658

Merged
merged 1 commit into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/blacklight/response/pagination_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class PaginationComponent < ::ViewComponent::Base
def initialize(response:, html: {}, **pagination_args)
@response = response
@html_attr = { aria: { label: t('views.pagination.aria.container_label') } }.merge(html)
@pagination_args = { outer_window: 2, theme: 'blacklight' }.merge(pagination_args)
@pagination_args = pagination_args
end

def pagination
helpers.paginate @response, **@pagination_args
helpers.paginate @response, **Blacklight::Engine.config.blacklight.default_pagination_options, **@pagination_args
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions lib/blacklight/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ class Engine < Rails::Engine

bl_global_config.facet_missing_param = '[* TO *]'

# These options are passed through to the kaminari #paginate helper
# https://www.rubydoc.info/gems/kaminari/1.2.2#helpers
bl_global_config.default_pagination_options = {
theme: 'blacklight',
outer_window: 2
}

# Anything that goes into Blacklight::Engine.config is stored as a class
# variable on Railtie::Configuration. we're going to encapsulate all the
# Blacklight specific stuff in this single struct:
Expand Down