diff --git a/app/helpers/blacklight_helper.rb b/app/helpers/blacklight_helper.rb
new file mode 100644
index 000000000..94d4500d2
--- /dev/null
+++ b/app/helpers/blacklight_helper.rb
@@ -0,0 +1,38 @@
+module BlacklightHelper
+ include Blacklight::BlacklightHelperBehavior
+ include Blacklight::CatalogHelperBehavior
+
+ ##
+ # Override the Blacklight Kaminari Override to better support custom group behavior
+ # @param [RSolr::Resource] collection (or other Kaminari-compatible objects)
+ # @return [String]
+ def page_entries_info(collection, options = {})
+ # Return to Blacklight implementation unless collection grouping is enabled
+ return super unless collection.respond_to?(:groups) && render_grouped_response?(collection)
+ return unless show_pagination? collection
+
+ entry_name = t('arclight.entry_name.grouped', count: collection.total_count)
+
+ end_num = collection.groups.length
+ end_num = if collection.offset_value + end_num <= collection.total_count
+ collection.offset_value + end_num
+ else
+ collection.total_count
+ end
+
+ case collection.total_count
+ when 0
+ t('arclight.search.pagination_info.no_items_found', entry_name: entry_name).html_safe
+ when 1
+ t('arclight.search.pagination_info.single_item_found', entry_name: entry_name).html_safe
+ else
+ t('arclight.search.pagination_info.pages', entry_name: entry_name,
+ current_page: collection.current_page,
+ num_pages: collection.total_pages,
+ start_num: number_with_delimiter(collection.offset_value + 1),
+ end_num: number_with_delimiter(end_num),
+ total_num: number_with_delimiter(collection.total_count),
+ count: collection.total_pages).html_safe
+ end
+ end
+end
diff --git a/config/locales/arclight.en.yml b/config/locales/arclight.en.yml
index b04393993..5c2700a74 100644
--- a/config/locales/arclight.en.yml
+++ b/config/locales/arclight.en.yml
@@ -5,6 +5,10 @@ en:
date_range_histogram:
hide: Hide date distribution
show: Show date distribution
+ entry_name:
+ grouped:
+ one: collection
+ other: collections
hierarchy:
scope_and_contents: Scope and Contents
view_all: View
@@ -16,6 +20,14 @@ en:
home: Home
repositories: Repositories
search_results: Search results
+ search:
+ pagination_info:
+ no_items_found: 'No %{entry_name} found'
+ single_item_found: '1 %{entry_name} found'
+ pages:
+ one: '%{start_num} - %{end_num} of %{total_num} %{entry_name}'
+ other: '%{start_num} - %{end_num} of %{total_num} %{entry_name}'
+
truncation:
view_less: view less ▼
view_more: view more ▶
diff --git a/spec/features/grouped_results_spec.rb b/spec/features/grouped_results_spec.rb
index 63de2792d..06906143f 100644
--- a/spec/features/grouped_results_spec.rb
+++ b/spec/features/grouped_results_spec.rb
@@ -52,4 +52,15 @@
end
end
end
+
+ describe 'custom pagination info' do
+ it 'displays with 1 collection' do
+ visit search_catalog_path q: 'alpha', group: 'true'
+ expect(page).to have_css '.page-entries', text: '1 collection found'
+ end
+ it 'displays with many collections' do
+ visit search_catalog_path q: '*', group: 'true'
+ expect(page).to have_css '.page-entries', text: '1 - 5 of 5 collections'
+ end
+ end
end