From 86a4d204ba055d0d71d07b2615ce7c9a0f981918 Mon Sep 17 00:00:00 2001 From: Sarah Proctor Date: Mon, 29 Jul 2024 17:34:23 -0700 Subject: [PATCH] :gift: Adds collection sorting by publication and creation date 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: - https://github.com/scientist-softserv/utk-hyku/issues/650 --- app/controllers/catalog_controller.rb | 12 ++++++++++++ app/indexers/collection_indexer.rb | 2 ++ 2 files changed, 14 insertions(+) diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index fbea25c8..15e46a92 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -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 @@ -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 = { diff --git a/app/indexers/collection_indexer.rb b/app/indexers/collection_indexer.rb index 2a7d63da..097e8e71 100644 --- a/app/indexers/collection_indexer.rb +++ b/app/indexers/collection_indexer.rb @@ -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