diff --git a/app/controllers/iiif/presentations_controller.rb b/app/controllers/iiif/presentations_controller.rb index f813406a6..163dc1408 100644 --- a/app/controllers/iiif/presentations_controller.rb +++ b/app/controllers/iiif/presentations_controller.rb @@ -13,7 +13,7 @@ class Iiif::PresentationsController < ApplicationController configure_blacklight do |config| Dcv::Configurators::DcvBlacklightConfigurator.configure(config) - config.show_fields.each { |field_key, show_field| show_field.link_to_search = false } + config.show_fields.each { |field_key, show_field| show_field.link_to_facet = false } end layout false diff --git a/app/helpers/field_display_helpers/name.rb b/app/helpers/field_display_helpers/name.rb index 9761fe2fa..33c489597 100644 --- a/app/helpers/field_display_helpers/name.rb +++ b/app/helpers/field_display_helpers/name.rb @@ -29,7 +29,7 @@ def display_names_with_roles(args={}) field_config = blacklight_config.show_fields[args[:field]] end - default_field = field_config.link_to_search if blacklight_config.facet_fields[field_config.link_to_search] + default_field = field_config.link_to_facet if blacklight_config.facet_fields[field_config.link_to_facet] names.map do |name, role_info| facet_field = role_info[:fields].detect { |field_name| blacklight_config.facet_fields[field_name]} || default_field value = (!args[:suppress_links] && facet_field) ? diff --git a/app/helpers/field_display_helpers/project.rb b/app/helpers/field_display_helpers/project.rb index 41f71ce79..d6cefd8c4 100644 --- a/app/helpers/field_display_helpers/project.rb +++ b/app/helpers/field_display_helpers/project.rb @@ -10,7 +10,7 @@ def show_digital_project?(field_config, document) end def show_field_project_to_facet_link(args) - return args[:document][args[:field]] unless blacklight_config.show_fields[args[:field]].link_to_search + return args[:document][args[:field]] unless blacklight_config.show_fields[args[:field]].link_to_facet projects_config = Rails.application.config_for(:hyacinth_projects) display_values = args[:document][args[:field]] diff --git a/app/helpers/field_display_helpers/repository.rb b/app/helpers/field_display_helpers/repository.rb index 92756e499..5ab094292 100644 --- a/app/helpers/field_display_helpers/repository.rb +++ b/app/helpers/field_display_helpers/repository.rb @@ -49,7 +49,7 @@ def show_field_repository_to_facet_link(args) facet_value = full_repo_names_to_short_repo_names[display_value] end - url_for_facet_search = search_action_path(:f => {facet_field_name => [facet_value]}) if blacklight_config.show_fields[args[:field]].link_to_search + url_for_facet_search = search_action_path(:f => {facet_field_name => [facet_value]}) if blacklight_config.show_fields[args[:field]].link_to_facet if display_value == 'Non-Columbia Location' && args[:document]['lib_repo_text_ssm'].present? result_src = [args[:document]['lib_repo_text_ssm'].first] diff --git a/app/models/site.rb b/app/models/site.rb index b562fc9fd..7eae6f82e 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -31,9 +31,9 @@ class Site < ApplicationRecord Dcv::Configurators::DcvBlacklightConfigurator.configure_show_fields(config) field_name = 'lib_repo_short_ssim' - config.show_fields[field_name].link_to_search = false + config.show_fields[field_name].link_to_facet = false field_name = 'lib_project_full_ssim' - config.show_fields[field_name].link_to_search = false + config.show_fields[field_name].link_to_facet = false Dcv::Configurators::DcvBlacklightConfigurator.configure_citation_fields(config) Dcv::Configurators::DcvBlacklightConfigurator.configure_sort_fields(config) diff --git a/app/presenters/dcv/field_presenter.rb b/app/presenters/dcv/field_presenter.rb index 3a72ef180..869d1f629 100644 --- a/app/presenters/dcv/field_presenter.rb +++ b/app/presenters/dcv/field_presenter.rb @@ -10,5 +10,10 @@ def label(context = 'index', **options) super end end + def pipeline_steps + upstream_operations = Blacklight::Rendering::Pipeline.operations.dup + upstream_operations.index(Blacklight::Rendering::LinkToFacet)&.tap { |ix| upstream_operations[ix] = Rendering::LinkToFacet } + (options[:steps] || field_config[:steps] || upstream_operations) - except_operations + end end end diff --git a/app/presenters/dcv/rendering/link_to_facet.rb b/app/presenters/dcv/rendering/link_to_facet.rb new file mode 100644 index 000000000..d6cb6b890 --- /dev/null +++ b/app/presenters/dcv/rendering/link_to_facet.rb @@ -0,0 +1,15 @@ +module Dcv + module Rendering + class LinkToFacet < Blacklight::Rendering::LinkToFacet + def render + return next_step(values) unless linkable_facet + + next_step(render_link) + end + + def linkable_facet + config.link_to_facet && context.blacklight_config.facet_fields[link_field] + end + end + end +end \ No newline at end of file diff --git a/lib/dcv/configurators/carnegie_blacklight_configurator.rb b/lib/dcv/configurators/carnegie_blacklight_configurator.rb index 90afca0b5..e122c1b07 100644 --- a/lib/dcv/configurators/carnegie_blacklight_configurator.rb +++ b/lib/dcv/configurators/carnegie_blacklight_configurator.rb @@ -63,7 +63,7 @@ def self.configure(config, fulltext: true) # The ordering of the field names is the order of the display # solr fields to be displayed in the show (single result) view # The ordering of the field names is the order of the display - config.add_show_field 'lib_name_ssm', label: 'Name', link_to_search: 'lib_name_sim', helper_method: :display_non_copyright_names_with_roles, if: :has_non_copyright_names? + config.add_show_field 'lib_name_ssm', label: 'Name', link_to_facet: 'lib_name_sim', helper_method: :display_non_copyright_names_with_roles, if: :has_non_copyright_names? config.add_show_field 'title_display_ssm', label: 'Title' config.add_show_field 'abstract_ssm', label: 'Abstract', helper_method: :expandable_past_400 config.add_show_field 'lib_collection_ssm', label: 'Collection Name', helper_method: :display_collection_with_links diff --git a/lib/dcv/configurators/dcv_blacklight_configurator.rb b/lib/dcv/configurators/dcv_blacklight_configurator.rb index 1bd1c054a..446be0b8c 100644 --- a/lib/dcv/configurators/dcv_blacklight_configurator.rb +++ b/lib/dcv/configurators/dcv_blacklight_configurator.rb @@ -113,8 +113,8 @@ def self.configure_index_fields(config) # The ordering of the field names is the order of the display def self.configure_show_fields(config) configure_file_show_fields(config) - config.add_show_field 'lib_name_ssm', label: 'Name', link_to_search: 'lib_name_sim', helper_method: :display_non_copyright_names_with_roles, if: :has_non_copyright_names? - config.add_show_field 'rel_other_project_ssim', :label => 'Project' + config.add_show_field 'lib_name_ssm', label: 'Name', link_to_facet: 'lib_name_sim', helper_method: :display_non_copyright_names_with_roles, if: :has_non_copyright_names? + config.add_show_field 'rel_other_project_ssim', label: 'Project', link_to_facet: true config.add_show_field 'title_display_ssm', label: 'Title' config.add_show_field 'alternative_title_ssm', :label => 'Other Titles' config.add_show_field 'abstract_ssm', label: 'Abstract', helper_method: :expandable_past_400, iiif: false @@ -132,14 +132,14 @@ def self.configure_show_fields(config) config.add_show_field 'lib_date_textual_ssm', :label => 'Date', :helper_method => :show_date_field config.add_show_field 'physical_description_extent_ssm', :label => 'Physical Description' config.add_show_field 'dynamic_notes', pattern: /lib_.*_notes_ssm/, label: :notes_label, helper_method: :expandable_past_250, unless: :is_excepted_dynamic_field?, except: ['lib_acknowledgment_notes_ssm'], join: false - config.add_show_field 'language_language_term_text_ssim', :label => 'Language', :link_to_search => 'language_language_term_text_ssim' + config.add_show_field 'language_language_term_text_ssim', label: 'Language', link_to_facet: 'language_language_term_text_ssim' config.add_show_field 'table_of_contents_ssm', :label => 'Contents' - config.add_show_field 'lib_repo_short_ssim', label: 'Library Location', helper_method: :show_field_repository_to_facet_link, link_to_search: true, iiif: false + config.add_show_field 'lib_repo_short_ssim', label: 'Library Location', helper_method: :show_field_repository_to_facet_link, link_to_facet: true, iiif: false config.add_show_field 'location_sublocation_ssm', :label => 'Department' config.add_show_field 'clio_ssim', label: 'Catalog Record', helper_method: :render_link_to_clio, join: false config.add_show_field 'lib_part_ssm', :label => 'Part' - config.add_show_field 'lib_project_full_ssim', label: 'Digital Project', helper_method: :show_field_project_to_facet_link, link_to_search: :project_key, if: :show_digital_project?, unless_fields: :project_key_ssim - config.add_show_field 'project_key_ssim', label: 'Digital Project', helper_method: :show_field_project_to_facet_link, link_to_search: :project_key, if: :show_digital_project? + config.add_show_field 'lib_project_full_ssim', label: 'Digital Project', helper_method: :show_field_project_to_facet_link, link_to_facet: :project_key, if: :show_digital_project?, unless_fields: :project_key_ssim + config.add_show_field 'project_key_ssim', label: 'Digital Project', helper_method: :show_field_project_to_facet_link, link_to_facet: :project_key, if: :show_digital_project? config.add_show_field 'other_sites_data', :label => 'Also In', :helper_method => :show_link_to_other_site_home # Note: Do NOT show the access_condition field. See DCV-465 for explanation. #config.add_show_field 'access_condition_ssim', :label => 'Rights' diff --git a/lib/dcv/configurators/jay_blacklight_configurator.rb b/lib/dcv/configurators/jay_blacklight_configurator.rb index 113dc4582..6f86f48b4 100644 --- a/lib/dcv/configurators/jay_blacklight_configurator.rb +++ b/lib/dcv/configurators/jay_blacklight_configurator.rb @@ -59,7 +59,7 @@ def self.configure(config) config.add_show_field 'title_display_ssm', :label => 'Title' config.add_show_field 'alternative_title_ssm', :label => 'Alternative Titles' config.add_show_field 'lib_repo_full_ssim', :label => 'Library Location', :helper_method => :show_field_repository_to_facet_link - config.add_show_field 'lib_name_ssm', label: 'Name', link_to_search: 'lib_name_sim', helper_method: :display_non_copyright_names_with_roles, if: :has_non_copyright_names? + config.add_show_field 'lib_name_ssm', label: 'Name', link_to_facet: 'lib_name_sim', helper_method: :display_non_copyright_names_with_roles, if: :has_non_copyright_names? config.add_show_field 'lib_format_ssm', :label => 'Format' config.add_show_field 'lib_project_full_ssim', :label => 'Digital Project' config.add_show_field 'lib_collection_ssm', :label => 'Collection' diff --git a/lib/dcv/configurators/lcaaj_blacklight_configurator.rb b/lib/dcv/configurators/lcaaj_blacklight_configurator.rb index 4ea871a42..e877ff2d1 100644 --- a/lib/dcv/configurators/lcaaj_blacklight_configurator.rb +++ b/lib/dcv/configurators/lcaaj_blacklight_configurator.rb @@ -63,8 +63,8 @@ def self.configure(config) # The ordering of the field names is the order of the display config.add_show_field 'title_display_ssm', :label => 'Title' config.add_show_field 'lib_repo_full_ssim', :label => 'Library Location', :helper_method => :show_field_repository_to_facet_link - config.add_show_field 'role_interviewer_ssim', :label => 'Interviewer', :sort => 'index', :link_to_search => 'role_interviewer_ssim' - config.add_show_field 'role_interviewee_ssim', :label => 'Interviewee', :sort => 'index', :link_to_search => 'role_interviewee_ssim' + config.add_show_field 'role_interviewer_ssim', label: 'Interviewer', sort: 'index', link_to_facet: 'role_interviewer_ssim' + config.add_show_field 'role_interviewee_ssim', label: 'Interviewee', sort: 'index', link_to_facet: 'role_interviewee_ssim' config.add_show_field 'lib_format_ssm', :label => 'Format' config.add_show_field 'subject_hierarchical_geographic_region_ssim', :label => 'Region' config.add_show_field 'subject_hierarchical_geographic_city_ssim', :label => 'City' diff --git a/lib/dcv/configurators/nyre_blacklight_configurator.rb b/lib/dcv/configurators/nyre_blacklight_configurator.rb index 764abf21a..f2fe66757 100644 --- a/lib/dcv/configurators/nyre_blacklight_configurator.rb +++ b/lib/dcv/configurators/nyre_blacklight_configurator.rb @@ -53,7 +53,7 @@ def self.configure(config) config.add_index_field 'lib_date_textual_ssm', :label => 'Date' config.add_index_field 'abstract_ssm', :label => 'Summary', :helper_method => :truncate_text_to_250 config.add_index_field 'cul_number_of_members_isi', :label => 'Number of Images' - config.add_index_field 'classification_other_ssim', :label => 'Call Number', :link_to_search => 'classification_other_ssim' + config.add_index_field 'classification_other_ssim', label: 'Call Number' config.add_index_field 'lib_name_ssm', label: 'Name', grid_display: true, if: false # solr fields to be displayed in the show (single result) view @@ -62,9 +62,9 @@ def self.configure(config) # The ordering of the field names is the order of the display config.add_show_field 'title_display_ssm', :label => 'Title' config.add_show_field 'lib_repo_full_ssim', :label => 'Library Location', :helper_method => :show_field_repository_to_facet_link - config.add_show_field 'role_architect_ssim', :label => 'Architect', :link_to_search => 'role_architect_ssim' - config.add_show_field 'role_owner_agent_ssim', :label => 'Owner/Agent', :link_to_search => 'role_owner_agent_ssim' - config.add_show_field 'classification_other_ssim', :label => 'Call Number', :link_to_search => 'classification_other_ssim' + config.add_show_field 'role_architect_ssim', label: 'Architect', link_to_facet: 'role_architect_ssim' + config.add_show_field 'role_owner_agent_ssim', label: 'Owner/Agent', link_to_facet: 'role_owner_agent_ssim' + config.add_show_field 'classification_other_ssim', label: 'Call Number', link_to_facet: 'classification_other_ssim' config.add_show_field 'lib_format_ssm', :label => 'Format' config.add_show_field 'subject_hierarchical_geographic_region_ssim', :label => 'Region' config.add_show_field 'subject_hierarchical_geographic_city_ssim', :label => 'City' diff --git a/lib/dcv/configurators/restricted/universityseminars_blacklight_configurator.rb b/lib/dcv/configurators/restricted/universityseminars_blacklight_configurator.rb index 02478fe04..330944460 100644 --- a/lib/dcv/configurators/restricted/universityseminars_blacklight_configurator.rb +++ b/lib/dcv/configurators/restricted/universityseminars_blacklight_configurator.rb @@ -59,7 +59,7 @@ def self.configure(config) # The ordering of the field names is the order of the display config.add_show_field 'title_display_ssm', :label => 'Title' config.add_show_field 'alternative_title_ssm', :label => 'Alternative Titles' - config.add_show_field 'primary_name_ssm', :label => 'Seminar Number', :link_to_search => 'primary_name_sim' + config.add_show_field 'primary_name_ssm', label: 'Seminar Number', link_to_facet: 'primary_name_sim' config.add_show_field 'lib_date_textual_ssm', :label => 'Date' config.add_show_field 'lib_non_date_notes_ssm', :label => 'Note' config.add_show_field 'lib_date_notes_ssm', :label => 'Date Note' diff --git a/spec/helpers/field_display_helpers/project_spec.rb b/spec/helpers/field_display_helpers/project_spec.rb index d14113dc5..35e50f760 100644 --- a/spec/helpers/field_display_helpers/project_spec.rb +++ b/spec/helpers/field_display_helpers/project_spec.rb @@ -34,14 +34,14 @@ let(:field_name) { :project_key_ssim } let(:field_values) { ['test'] } before do - blacklight_config.add_show_field field_name, label: 'Digital Project', helper_method: :show_field_project_to_facet_link, link_to_search: true + blacklight_config.add_show_field field_name, label: 'Digital Project', helper_method: :show_field_project_to_facet_link, link_to_facet: true end it { is_expected.to satisfy {|x| x.length == field_values.length} } it { is_expected.to satisfy {|x| x[0].include?(">Successful Project Mapping For Full Project Title") } } end context "field is not linked" do before do - blacklight_config.add_show_field field_name, label: 'Digital Project', helper_method: :show_field_project_to_facet_link, link_to_search: false + blacklight_config.add_show_field field_name, label: 'Digital Project', helper_method: :show_field_project_to_facet_link, link_to_facet: false end it { is_expected.to satisfy {|x| x.length == 2} } it { is_expected.to satisfy {|x| x[0].eql?("Project 1") && x[1].eql?("Project 2") } } diff --git a/spec/presenters/dcv/field_presenter_spec.rb b/spec/presenters/dcv/field_presenter_spec.rb new file mode 100644 index 000000000..21eedd074 --- /dev/null +++ b/spec/presenters/dcv/field_presenter_spec.rb @@ -0,0 +1,30 @@ +require 'rails_helper' + +describe Dcv::FieldPresenter do + include_context "a solr document" + + let(:blacklight_config) { Blacklight::Configuration.new } + let(:search_action_path) { '/search' } + let(:search_state) { Dcv::SearchState.new({}, blacklight_config) } + let(:view_context) { double(ActionController::Base, blacklight_config: blacklight_config, search_state: search_state, search_action_path: search_action_path) } + let(:presenter) { described_class.new(view_context, solr_document, blacklight_config.show_fields['dc_type_ssm']) } + + before do + blacklight_config.add_show_field 'dc_type_ssm', label: 'DcType', link_to_facet: true + end + + it "does not link the values without a configured facet" do + expect(presenter.render).to eql "Unknown" + end + + context "facet field is configured" do + before do + blacklight_config.add_facet_field 'dc_type_ssm', label: 'DcType' + allow(view_context).to receive(:link_to).and_return ('success') + end + + it "links the values" do + expect(presenter.render).to eql "success" + end + end +end \ No newline at end of file