Skip to content

Commit

Permalink
Merge pull request #6178 from avalonmediasystem/rights_facet
Browse files Browse the repository at this point in the history
Add rights statement facet
  • Loading branch information
cjcolvar authored Jan 24, 2025
2 parents 2dbb270 + 043e989 commit 0edb0c1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class CatalogController < ApplicationController
config.add_facet_field 'collection_ssim', label: 'Collection', limit: 5
config.add_facet_field 'unit_ssim', label: 'Unit', limit: 5
config.add_facet_field 'language_ssim', label: 'Language', limit: 5
config.add_facet_field 'rights_statement_ssi', label: 'Rights Statement', limit: 5, helper_method: :rights_statement_facet_display

# Hide these facets if not a Collection Manager
config.add_facet_field 'workflow_published_sim', label: 'Published', limit: 5, if: Proc.new {|context, config, opts| context.current_ability.can? :create, MediaObject}, group: "workflow"
config.add_facet_field 'avalon_uploader_ssi', label: 'Created by', limit: 5, if: Proc.new {|context, config, opts| context.current_ability.can? :create, MediaObject}, group: "workflow"
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/blacklight/local_blacklight_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def facet_group_names
blacklight_config.facet_fields.map {|facet,opts| opts[:group]}.uniq
end

def rights_statement_facet_display arg
ModsDocument::RIGHTS_STATEMENTS[arg]
end

def contributor_index_display args
args[:document][args[:field]].first(3).join("; ")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/catalog_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
MediaObjectIndexingJob.perform_now(media_object.id)
end
["avalon_resource_type_ssim", "creator_ssim", "date_sim", "genre_ssim", "series_ssim", "collection_ssim", "unit_ssim", "language_ssim", "has_captions_bsi", "has_transcripts_bsi",
"workflow_published_sim", "avalon_uploader_ssi", "read_access_group_ssim", "read_access_virtual_group_ssim", "date_digitized_ssim", "date_ingested_ssim", "subject_ssim"].each do |field|
"workflow_published_sim", "avalon_uploader_ssi", "read_access_group_ssim", "read_access_virtual_group_ssim", "date_digitized_ssim", "date_ingested_ssim", "subject_ssim", "rights_statement_ssi"].each do |field|
it "should facet results on #{field}" do
query = Array(media_object.to_solr(include_child_fields:true)[field]).first
# The following line is to check that the test is using a valid solr field name
Expand Down
1 change: 1 addition & 0 deletions spec/features/capybara_catalog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
expect(page).to have_selector(:id, "facet-#{field}_ssim-header")
end
expect(page).to have_selector(:id, "facet-date_sim-header")
expect(page).to have_selector(:id, "facet-rights_statement_ssi-header")
['workflow_published_sim', 'avalon_uploader_ssi', 'read_access_group_ssim', 'read_access_virtual_group_ssim', 'date_digitized_ssim', 'date_ingested_ssim'].each do |field|
expect(page).to_not have_selector(:id, "facet-#{field}-header")
end
Expand Down

0 comments on commit 0edb0c1

Please sign in to comment.