Skip to content

Commit a7b60f9

Browse files
committed
DLC-1143 WIP
1 parent 8a0b364 commit a7b60f9

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

app/components/dcv/document_component.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Dcv
44
class DocumentComponent < Blacklight::DocumentComponent
55
delegate :byte_size_to_text_string, :render_document_class, :render_document_tombstone_field_value, :render_snippet_with_post_processing, to: :helpers
6-
6+
delegate :load_subsite, to: :controller
77
# this is a BL8 forward-compatible override
88
# - BL8 will pass DocumentPresenter as :document
99
# - BL8 will use ViewComponent collection iteration
@@ -29,9 +29,9 @@ def initialize(document:, partials: nil,
2929
@id = id || ('document' if show)
3030
@classes = classes
3131

32-
@metadata_component = Blacklight::DocumentMetadataComponent
32+
@metadata_component = metadata_component || Blacklight::DocumentMetadataComponent
3333

34-
@thumbnail_component = Blacklight::Document::ThumbnailComponent
34+
@thumbnail_component = thumbnail_component || Blacklight::Document::ThumbnailComponent
3535

3636
# ViewComponent 3 will change document_counter to be zero-based, but BL8 will accommodate
3737
@counter = document_counter + counter_offset if document_counter.present?
@@ -86,8 +86,10 @@ def short_title
8686
end
8787

8888
def document_tombstone_fields(document = nil)
89+
tombstone_fields = load_subsite.search_configuration.display_options.tombstone_fields
8990
helpers.blacklight_config.index_fields.select do |field, field_config|
90-
field_config[:tombstone_display] && document[field].present?
91+
tombstone_display = (field_config[:tombstone_display] == true) || (tombstone_fields & Array(field_config[:tombstone_display])).present?
92+
tombstone_display && document[field].present?
9193
end.to_h
9294
end
9395
end

app/controllers/sites/search_configuration_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ def search_configuration_params
4242
.require(:search_configuration).permit(
4343
date_search_configuration: [:enabled, :granularity_search, :show_sidebar, :show_timeline, :sidebar_label],
4444
map_configuration: [:default_lat, :default_long, :enabled, :granularity_data, :granularity_search, :show_items, :show_sidebar],
45-
display_options: [:default_search_mode, :show_csv_results, :show_original_file_download, :show_other_sources],
45+
display_options: [:default_search_mode, :show_csv_results, :show_original_file_download, :show_other_sources, :tombstone_fields],
4646
facets: [:facet_fields_form_value, :label, :limit, :sort, :value_transforms],
4747
search_fields: [:type, :label]
4848
)&.to_h
4949
# todo: find a better way to unroll the list of values
5050
scp&.tap do |atts|
5151
atts['search_fields'] = atts['search_fields'].values if atts&.fetch('search_fields', nil)
5252
atts['facets'] = atts['facets'].values if atts&.fetch('facets', nil)
53+
display_options = atts['display_options']
54+
display_options['tombstone_fields'] = display_options['tombstone_fields'].split(',').map(&:strip) if display_options&.fetch('tombstone_fields', nil)
5355
end
5456
end
5557
end

app/models/site/display_options.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ class Site::DisplayOptions
44
include ActiveRecord::AttributeAssignment
55
include Site::ConfigurationValues
66

7-
define_attribute_methods :default_search_mode, :show_csv_results, :show_original_file_download, :show_other_sources
8-
attr_accessor :default_search_mode, :show_csv_results, :show_original_file_download, :show_other_sources
7+
define_attribute_methods :default_search_mode, :show_csv_results, :show_original_file_download, :show_other_sources, :tombstone_fields
8+
attr_accessor :default_search_mode, :show_csv_results, :show_original_file_download, :show_other_sources, :tombstone_fields
99

10-
VALID_SEARCH_MODES = ['grid', 'list'].freeze
10+
VALID_SEARCH_MODES = %w(grid list).freeze
11+
VALID_TOMBSTONE_OPTIONS = %w(format name project).freeze
1112

1213
def default_configuration
13-
{ default_search_mode: 'grid', show_csv_results: false, show_original_file_download: false, show_other_sources: false }
14+
{
15+
default_search_mode: 'grid', show_csv_results: false, show_original_file_download: false,
16+
show_other_sources: false, tombstone_fields: ['name'] }
1417
end
1518

1619
def initialize(atts = {})
@@ -23,6 +26,10 @@ def default_search_mode=(val)
2326
@default_search_mode = VALID_SEARCH_MODES.include?(val) ? val : 'grid'
2427
end
2528

29+
def tombstone_fields=(vals)
30+
@tombstone_fields = Array(vals).map(&:to_s).map(&:downcase).select { |v| VALID_TOMBSTONE_OPTIONS.include?(v) }
31+
end
32+
2633
def show_csv_results=(val)
2734
val = boolean_or_nil(val)
2835
show_csv_results_will_change! unless val == @show_csv_results
@@ -55,7 +62,8 @@ def serializable_hash(opts = {})
5562
'default_search_mode' => @default_search_mode,
5663
'show_csv_results' => @show_csv_results,
5764
'show_original_file_download' => @show_original_file_download,
58-
'show_other_sources' => @show_other_sources
65+
'show_other_sources' => @show_other_sources,
66+
'tombstone_fields' => @tombstone_fields || []
5967
}.tap {|v| v.compact! if opts&.fetch(:compact, false)}
6068
end
6169
end

app/views/sites/search_configuration/_display_options_form.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
</label>
1616
</div>
1717
</div>
18+
<div class="form-group">
19+
<label for="site_search_configuration_display_options_tombstone_fields">"Tombstone" Result Display <span class="fa fa-question-circle" data-tooltip="tooltip-display-tombstone"></span></label>
20+
<%= options_form.text_field(:tombstone_fields, {value: @subsite.search_configuration.display_options.tombstone_fields.join(", "), class: ['form-control'], disabled: !can?(:admin, @subsite)}) %>
21+
</div>
1822
<div class="form-group">
1923
<label for="site_search_configuration_display_options_show_csv_results">Allow CSV Search Results <span class="fa fa-question-circle" data-tooltip="tooltip-display-csv"></span></label>
2024
<%= options_form.check_box :show_csv_results, {}, "true", "false" %>
@@ -40,4 +44,5 @@
4044
<span id="tooltip-display-csv" title="Allow CSV Search Results">Configure the site to make search results available as a CSV download (linked from the results page).</span>
4145
<span id="tooltip-display-original-files" title="Allow Original File Downloads">Configure the site to link original file downloads where available (useful for born-digital content, such as office documents or spreadsheets). Editing is currently disabled.</span>
4246
<span id="tooltip-display-other-sources" title="Link to Other Search Sources">Configure the site to include a link to alternate search sources relevant to site content. Editing is currently disabled.</span>
47+
<span id="tooltip-display-tombstone" title="'Tombstone' Result Display">Configure the field types (<%= Site::DisplayOptions::VALID_TOMBSTONE_OPTIONS.join(", ") %>) to display in search result "tombstones" (the compact/grid view).</span>
4348
</div>

lib/dcv/configurators/dcv_blacklight_configurator.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,14 @@ def self.configure_sort_fields(config)
9999
# The ordering of the field names is the order of the display
100100
def self.configure_index_fields(config)
101101
config.add_index_field 'primary_name_ssm', label: 'Name', helper_method: :display_non_copyright_names_with_roles, if: :has_non_copyright_names?
102-
config.add_index_field 'rel_other_project_ssim', :label => 'Project'
102+
config.add_index_field 'rel_other_project_ssim', label: 'Project', tombstone_display: ['project']
103103
config.add_index_field 'lib_repo_long_ssim', :label => 'Library Location'
104104
config.add_index_field 'location_sublocation_ssm', :label => 'Department'
105105
config.add_index_field 'lib_collection_ssm', label: 'Collection Name', helper_method: :display_composite_archival_context
106106
config.add_index_field 'lib_date_textual_ssm', :label => 'Date'
107107
config.add_index_field 'lib_item_in_context_url_ssm', :label => 'Item in Context', :helper_method => :link_to_url_value
108-
config.add_index_field 'lib_name_ssm', label: 'Name', tombstone_display: true, if: false
108+
config.add_index_field 'lib_name_ssm', label: 'Name', tombstone_display: ['name'], if: false
109+
config.add_index_field 'lib_format_ssm', label: 'Format', tombstone_display: ['format'], if: false
109110
end
110111

111112
# solr fields to be displayed in the show (single result) view

0 commit comments

Comments
 (0)