Skip to content

Commit

Permalink
🎁 Adds collection sorting by publication and creation date
Browse files Browse the repository at this point in the history
This commit adds collection search options for sorting by ascending and descending publication dates and ascending and descending creation dates to the dropdown menu.

Ref:
- #650
  • Loading branch information
sjproctor committed Jul 30, 2024
1 parent eb26094 commit 86a4d20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ def self.title_field
'title_ssi'
end

def self.published_field
'date_issued_d_ssi'
end

def self.created_field
'date_created_d_ssi'
end

# CatalogController-scope behavior and configuration for BlacklightIiifSearch
include BlacklightIiifSearch::Controller

Expand Down Expand Up @@ -396,6 +404,10 @@ def self.title_field
config.add_sort_field "#{uploaded_field} asc", label: "date uploaded \u25B2"
config.add_sort_field "#{modified_field} desc", label: "date modified \u25BC"
config.add_sort_field "#{modified_field} asc", label: "date modified \u25B2"
config.add_sort_field "#{published_field} desc", label: "date published \u25BC"
config.add_sort_field "#{published_field} asc", label: "date published \u25B2"
config.add_sort_field "#{created_field} desc", label: "date created \u25BC"
config.add_sort_field "#{created_field} asc", label: "date created \u25B2"

# OAI Config fields
config.oai = {
Expand Down
2 changes: 2 additions & 0 deletions app/indexers/collection_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def generate_solr_document
solr_doc["bulkrax_identifier_sim"] = object.bulkrax_identifier
solr_doc["account_cname_tesim"] = Site.instance&.account&.cname
solr_doc[CatalogController.title_field] = object.title.first
solr_doc[CatalogController.published_field] = object.date_issued_d
solr_doc[CatalogController.created_field] = object.date_created_d
end
end

Expand Down

0 comments on commit 86a4d20

Please sign in to comment.