From 098eccfa0a146057767e298c6fc44d4eaba00ff5 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Fri, 23 Aug 2024 15:19:34 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=81=20Add=20campus=20to=20facets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will render the campus in the facets field. All of the changes came from the current ngao app. Ref: - https://github.com/scientist-softserv/archives_online/issues/19 --- app/controllers/catalog_controller.rb | 5 +++++ app/helpers/application_helper.rb | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index b2732b6..2c679f6 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -138,6 +138,7 @@ class CatalogController < ApplicationController # :index_range can be an array or range of prefixes that will be used to create the navigation # (note: It is case sensitive when searching values) + config.add_facet_field 'campus_unit_sim', label: 'Campus', helper_method: :render_campus_facet config.add_facet_field 'collection', field: 'collection_ssim', limit: 10 config.add_facet_field 'creators', field: 'creator_ssim', limit: 10 config.add_facet_field 'date_range', field: 'date_range_isim', range: true @@ -152,6 +153,8 @@ class CatalogController < ApplicationController # handler defaults, or have no facets. config.add_facet_fields_to_solr_request! + config.add_index_field 'campus_unit_ssm', label: 'Campus', helper_method: :render_campus_name + # solr fields to be displayed in the index (search results) view # The ordering of the field names is the order of the display config.add_index_field 'highlight', accessor: 'highlights', separator_options: { @@ -423,6 +426,8 @@ class CatalogController < ApplicationController # Collection and Component Show Page Access Tab - How to Cite Section config.add_cite_field 'prefercite', field: 'prefercite_html_tesm', helper_method: :render_html_tags + config.add_contact_field 'campus_unit_ssm', label: 'Campus', helper_method: :render_campus_name + # Collection and Component Show Page Access Tab - Contact Section config.add_contact_field 'repository_contact', values: ->(_, document, _) { document.repository_config&.contact } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ecbd349..3e93815 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -6,4 +6,13 @@ module ApplicationHelper def additional_locale_routing_scopes [blacklight, arclight_engine] end + + def render_campus_name(args) + key = args[:value] || [] + convert_campus_id(key[0]) + end + + def render_campus_facet(options = {}) + convert_campus_id(options) + end end