Class: SirTrevorRails::Blocks::SolrDocumentsBlock
Overview
Multi-up document viewer with text block
Constant Summary
SirTrevorRails::Block::DEFAULT_FORMAT
Instance Attribute Summary collapse
#parent, #type
Instance Method Summary
collapse
#item_ids, #items, #ordered_items
Methods included from Textable
#content_align, #text, #text?, #text_align
#as_json, block_class, block_class!, custom_block_types, #format, from_hash, #initialize, #to_partial_path, type_klass
Instance Attribute Details
#solr_helper ⇒ Object
Returns the value of attribute solr_helper.
10
11
12
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 10
def solr_helper
@solr_helper
end
|
Instance Method Details
#document_caption(presenter, caption_field, default: nil) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 51
def document_caption(presenter, caption_field, default: nil)
caption_field ||= default
return unless caption_field
return presenter.heading if caption_field == Spotlight::PageConfigurations::DOCUMENT_TITLE_KEY
presenter.field_value(solr_helper.blacklight_config.index_fields[caption_field] || null_display_field_class.new(caption_field))
end
|
#documents ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 26
def documents
@documents ||= begin
doc_ids = items.pluck(:id)
result = solr_helper.controller.send(:search_service).fetch(doc_ids)
if result.first.is_a? Blacklight::Solr::Response
result.last
else
result
end
end
end
|
#documents? ⇒ Boolean
39
40
41
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 39
def documents?
each_document.any?
end
|
#each_document ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 16
def each_document
return to_enum(:each_document) unless block_given?
items.each do |i|
document = documents.detect { |doc| doc.id == i[:id] }
i[:iiif_tilesource_base] = i.fetch(:iiif_tilesource, '').sub('/info.json', '')
yield i, document if document
end
end
|
#null_display_field_class ⇒ Object
82
83
84
85
86
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 82
def null_display_field_class
return Blacklight::Configuration::NullDisplayField if defined?(Blacklight::Configuration::NullDisplayField)
Blacklight::Configuration::NullField
end
|
#primary_caption? ⇒ Boolean
43
44
45
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 43
def primary_caption?
primary_caption_field.present? && show_primary_caption?
end
|
#primary_caption_field ⇒ Object
72
73
74
75
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 72
def primary_caption_field
val = send(:'primary-caption-field')
val.presence
end
|
#secondary_caption? ⇒ Boolean
60
61
62
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 60
def secondary_caption?
secondary_caption_field.present? && show_secondary_caption?
end
|
#secondary_caption_field ⇒ Object
77
78
79
80
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 77
def secondary_caption_field
val = send(:'secondary-caption-field')
val.presence
end
|
#show_primary_caption? ⇒ Boolean
47
48
49
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 47
def show_primary_caption?
ActiveModel::Type::Boolean.new.cast(send(:'show-primary-caption'))
end
|
#show_secondary_caption? ⇒ Boolean
64
65
66
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 64
def show_secondary_caption?
ActiveModel::Type::Boolean.new.cast(send(:'show-secondary-caption'))
end
|
#with_solr_helper(solr_helper) ⇒ Object
12
13
14
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 12
def with_solr_helper(solr_helper)
@solr_helper = solr_helper
end
|
#zpr_link? ⇒ Boolean
68
69
70
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 68
def zpr_link?
zpr_link == 'true'
end
|