Class: SirTrevorRails::Blocks::BrowseBlock
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
#item_ids, #items, #ordered_items
custom_block_types
Instance Attribute Details
#solr_helper ⇒ Object
Returns the value of attribute solr_helper.
10
11
12
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 10
def solr_helper
@solr_helper
end
|
Instance Method Details
#as_json ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 34
def as_json
result = super
result[:data][:item] ||= {}
result[:data][:item].select! { |_, v| parent.exhibit.searches.exists?(v['id']) }
result[:data][:item].each_value do |v|
v['thumbnail_image_url'] = parent.exhibit.searches.find(v['id']).thumbnail_image_url
end
result
end
|
#display_item_counts? ⇒ Boolean
30
31
32
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 30
def display_item_counts?
send(:'display-item-counts') == 'true'
end
|
#search_options(id) ⇒ Object
16
17
18
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 16
def search_options(id)
(items.detect { |x| x[:id] == id }) || {}
end
|
#searches ⇒ Object
20
21
22
23
24
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 20
def searches
@searches ||= parent.exhibit.searches.published.where(slug: item_ids).sort do |a, b|
ordered_items.index(a.slug) <=> ordered_items.index(b.slug)
end
end
|
#searches? ⇒ Boolean
26
27
28
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 26
def searches?
!searches.empty?
end
|
#with_solr_helper(solr_helper) ⇒ Object
12
13
14
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 12
def with_solr_helper(solr_helper)
@solr_helper = solr_helper
end
|