Skip to content

Commit

Permalink
🎁 BONUS: Display QA term instead of id in search results and facets
Browse files Browse the repository at this point in the history
This commit adds helper methods to department so that the value will display the terms instead of the id, in the catalog search index and facets. For example, "history" instead of "hst". You could write a spec for these methods for reassurance, and know that this is not the only way to accomplish this. With customizations the dev will often have to come up with solutions of their own.

:gift: BONUS: Display QA term instead of id in search results and facets

This commit adds helper methods to department so that the value will display the terms instead of the id, in the catalog search index and facets. For example, "history" instead of "hst". You could write a spec for these methods for reassurance, and know that this is not the only way to accomplish this. With customizations the dev will often have to come up with solutions of their own.

:broom: Add resource_type back to the catalog controller

Removing this was an accident.

:broom: Remove the link from the catalog search result

Having this be linkable caused an issue so for now, I am removing it until I have time to look into it.
  • Loading branch information
ShanaLMoore committed Sep 20, 2023
1 parent f4535db commit dac5671
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def self.modified_field
config.add_facet_field 'resource_type_sim', label: "Resource Type", limit: 5
config.add_facet_field 'creator_sim', limit: 5
config.add_facet_field 'contributor_sim', label: "Contributor", limit: 5
config.add_facet_field 'department_sim', label: "Department", limit: 5, helper_method: :department_facets
config.add_facet_field 'keyword_sim', limit: 5
config.add_facet_field 'subject_sim', limit: 5
config.add_facet_field 'language_sim', limit: 5
Expand Down Expand Up @@ -102,14 +103,14 @@ def self.modified_field
config.add_index_field 'date_uploaded_dtsi', itemprop: 'datePublished', helper_method: :human_readable_date
config.add_index_field 'date_modified_dtsi', itemprop: 'dateModified', helper_method: :human_readable_date
config.add_index_field 'date_created_tesim', itemprop: 'dateCreated'
config.add_index_field 'resource_type_tesim', label: "Resource Type", link_to_search: 'resource_type_sim'
config.add_index_field 'rights_statement_tesim', helper_method: :rights_statement_links
config.add_index_field 'license_tesim', helper_method: :license_links
config.add_index_field 'resource_type_tesim', label: "Resource Type", link_to_search: 'resource_type_sim'
config.add_index_field 'file_format_tesim', link_to_search: 'file_format_sim'
config.add_index_field 'identifier_tesim', helper_method: :index_field_link, field_name: 'identifier'
config.add_index_field 'embargo_release_date_dtsi', label: "Embargo release date", helper_method: :human_readable_date
config.add_index_field 'lease_expiration_date_dtsi', label: "Lease expiration date", helper_method: :human_readable_date
config.add_index_field 'department_tesim', label: "Department", link_to_search: 'department_sim'
config.add_index_field 'department_tesim', label: "Department", helper_method: :department_links

# solr fields to be displayed in the show (single result) view
# The ordering of the field names is the order of the display
Expand Down
9 changes: 9 additions & 0 deletions app/helpers/hyrax/override_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,14 @@ def search_state_with_facets(params, facet = {})
state.add_facet_params("#{facet.keys.first}_sim",
facet.values.first)
end

def department_facets(options)
DepartmentsService.label(options)
end

def department_links(options)
service = DepartmentsService
options[:value].map { |department_id| service.label(department_id) }.join(', ')
end
end
end

0 comments on commit dac5671

Please sign in to comment.