diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index ba9e9133..54114dfc 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -196,6 +196,14 @@ def self.modified_field } end + config.add_search_field('content_genre') do |field| + solr_name = 'content_genre_ssi' + field.solr_local_parameters = { + qf: solr_name, + pf: solr_name + } + end + config.add_search_field('subject') do |field| solr_name = "subject_tesim" field.solr_local_parameters = { @@ -277,6 +285,30 @@ def self.modified_field } end + config.add_search_field('research_categories') do |field| + solr_name = "research_categories_ssim" + field.solr_local_parameters = { + qf: solr_name, + pf: solr_name + } + end + + config.add_search_field('parent_title') do |field| + solr_name = "parent_title_ssi" + field.solr_local_parameters = { + qf: solr_name, + pf: solr_name + } + end + + config.add_search_field('publisher_version') do |field| + solr_name = "publisher_version_ssi" + field.solr_local_parameters = { + qf: solr_name, + pf: solr_name + } + end + # "sort results by" select (pulldown) # label in pulldown is followed by the name of the SOLR field to sort by and # whether the sort is ascending or descending (it must be asc or desc diff --git a/app/renderers/hyrax/renderers/custom_faceted_attribute_renderer.rb b/app/renderers/hyrax/renderers/custom_faceted_attribute_renderer.rb new file mode 100644 index 00000000..ea9639e6 --- /dev/null +++ b/app/renderers/hyrax/renderers/custom_faceted_attribute_renderer.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true +# frozen_string_literal: true +module Hyrax + module Renderers + class CustomFacetedAttributeRenderer < AttributeRenderer + private + + def li_value(value) + link_to(ERB::Util.h(value), search_path(value)) + end + + def search_path(value) + Rails.application.routes.url_helpers.search_catalog_path("f[#{search_field}][]": value, locale: I18n.locale) + end + + def search_field + options.fetch(:search_field, field) + end + end + end +end diff --git a/app/views/hyrax/base/_attribute_rows.html.erb b/app/views/hyrax/base/_attribute_rows.html.erb index 71d758ac..4e578860 100644 --- a/app/views/hyrax/base/_attribute_rows.html.erb +++ b/app/views/hyrax/base/_attribute_rows.html.erb @@ -1,6 +1,7 @@ <% generic_renderer = ::Hyrax::Renderers::AttributeRenderer %> +<% custom_facet_renderer = ::Hyrax::Renderers::CustomFacetedAttributeRenderer %> <% facet_renderer = ::Hyrax::Renderers::FacetedAttributeRenderer %> <% external_link_renderer = ::Hyrax::Renderers::ExternalLinkAttributeRenderer %> <% content_type_term = SelfDeposit::ContentTypesService.label(presenter.solr_document['emory_content_type_tesi']) %> @@ -8,19 +9,24 @@ <%= render 'purl', presenter: presenter %> <%= presenter.attribute_to_html(:date_modified, label: t('hyrax.base.show.last_modified'), html_dl: true) %> -<%= facet_renderer.new(:content_genre, presenter.solr_document['content_genre_ssi'], {}).render_dl_row %> +<%= custom_facet_renderer.new('content_genre', + presenter.solr_document['content_genre_ssi'], {search_field: 'content_genre_ssi'}).render_dl_row %> <%= render 'creator', presenter: presenter %> -<%= presenter.attribute_to_html(:language, render_as: :faceted, html_dl: true) %> -<%= facet_renderer.new(:date_issued, presenter.solr_document['date_issued_ssi'], {}).render_dl_row %> +<%= custom_facet_renderer.new('language', + presenter.solr_document['language_tesim'], {search_field: 'language_tesim'}).render_dl_row %> +<%= custom_facet_renderer.new('date_issued', + presenter.solr_document['date_issued_ssi'], {search_field: 'date_issued_year_ssi'}).render_dl_row %> <%= presenter.attribute_to_html(:publisher, render_as: :faceted, html_dl: true) %> -<%= facet_renderer.new(:publisher_version, presenter.solr_document['publisher_version_ssi'], {}).render_dl_row %> +<%= custom_facet_renderer.new('publisher_version', + presenter.solr_document['publisher_version_ssi'], {search_field: 'publisher_version_ssi'}).render_dl_row %> <% if current_user.try(:admin?) %> <%= presenter.attribute_to_html(:rights_statement, render_as: :rights_statement, html_dl: true) %> <% end %> <%= presenter.attribute_to_html(:rights_notes, html_dl: true) %> <%= ::Hyrax::Renderers::LicenseAttributeRenderer.new(:license, presenter.solr_document['license_tesi'], {}).render_dl_row %> <%= generic_renderer.new(:final_published_versions, presenter.solr_document['final_published_versions_tesim'], {}).render_dl_row %> -<%= facet_renderer.new(:parent_title, presenter.solr_document['parent_title_ssi'], {}).render_dl_row %> +<%= custom_facet_renderer.new('parent_title', + presenter.solr_document['parent_title_ssi'], {search_field: 'parent_title_ssi'}).render_dl_row %> <%= facet_renderer.new(:conference_name, presenter.solr_document['conference_name_ssi'], {}).render_dl_row %> <%= generic_renderer.new(:issn, presenter.solr_document['issn_tesi'], {}).render_dl_row %> <%= generic_renderer.new(:isbn, presenter.solr_document['isbn_tesi'], {}).render_dl_row %> @@ -39,7 +45,8 @@ <%= generic_renderer.new(:author_notes, presenter.solr_document['author_notes_tesi'], {}).render_dl_row %> <%= presenter.attribute_to_html(:keyword, render_as: :faceted, html_dl: true) %> <%= presenter.attribute_to_html(:subject, render_as: :faceted, html_dl: true) %> -<%= facet_renderer.new(:research_categories, presenter.solr_document['research_categories_ssim'], {}).render_dl_row %> +<%= custom_facet_renderer.new('research_categories', + presenter.solr_document['research_categories_ssim'], {search_field: 'research_categories_ssim'}).render_dl_row %> <% if current_user.try(:admin?) %> <%= generic_renderer.new(:emory_ark, presenter.solr_document['emory_ark_tesim'], {}).render_dl_row %> <%= generic_renderer.new(:internal_rights_note, presenter.solr_document['internal_rights_note_tesi'], {}).render_dl_row %> diff --git a/app/views/hyrax/base/relationships_parent_row.html.erb b/app/views/hyrax/base/relationships_parent_row.html.erb new file mode 100644 index 00000000..e80ab6e7 --- /dev/null +++ b/app/views/hyrax/base/relationships_parent_row.html.erb @@ -0,0 +1,14 @@ +
<%= t(".label", type: type.humanize) %>
+
+ <% if items.blank? %> +

<%= t('.empty', type: type.humanize) %>

+ <% else %> + + <% end %> +
\ No newline at end of file diff --git a/app/views/hyrax/base/relationships_parent_rows.html.erb b/app/views/hyrax/base/relationships_parent_rows.html.erb new file mode 100644 index 00000000..f6997d6b --- /dev/null +++ b/app/views/hyrax/base/relationships_parent_rows.html.erb @@ -0,0 +1,17 @@ +<% custom_facet_renderer = ::Hyrax::Renderers::CustomFacetedAttributeRenderer %> +<%# Render presenters which aren't specified in the 'presenter_types' %> +<% presenter.grouped_presenters(except: presenter.presenter_types).each_pair do |model_name, items| %> + <%= render 'relationships_parent_row', type: model_name, items: items, presenter: presenter %> +<% end %> + +<%# Render grouped presenters. Show rows if there are any items of that type %> +<% presenter.presenter_types.each do |type| %> + <% presenter.grouped_presenters(filtered_by: type).each_pair do |_, items| %> + <%= render 'relationships_parent_row', type: type, items: items, presenter: presenter %> + <% end %> +<% end %> + +<% if current_user %> +<%= custom_facet_renderer.new('admin_set_tesim', + presenter.solr_document['admin_set_tesim'], {}).render_dl_row %> +<% end %> \ No newline at end of file