-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom pagination information for grouped responses fixes #699
- Loading branch information
1 parent
66dd349
commit 1ed0033
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters