Class: SirTrevorRails::Blocks::BrowseBlock
- Inherits:
-
SirTrevorRails::Block
- Object
- SirTrevorRails::Block
- SirTrevorRails::Blocks::BrowseBlock
show all
- Includes:
- Displayable
- Defined in:
- app/models/sir_trevor_rails/blocks/browse_block.rb
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
#item_ids, #items, #ordered_items
Instance Attribute Details
#solr_helper ⇒ Object
Returns the value of attribute solr_helper.
8
9
10
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 8
def solr_helper
@solr_helper
end
|
Instance Method Details
#as_json ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 32
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
28
29
30
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 28
def display_item_counts?
send(:'display-item-counts') == 'true'
end
|
#search_options(id) ⇒ Object
14
15
16
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 14
def search_options(id)
(items.detect { |x| x[:id] == id }) || {}
end
|
#searches ⇒ Object
18
19
20
21
22
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 18
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
24
25
26
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 24
def searches?
!searches.empty?
end
|
#with_solr_helper(solr_helper) ⇒ Object
10
11
12
|
# File 'app/models/sir_trevor_rails/blocks/browse_block.rb', line 10
def with_solr_helper(solr_helper)
@solr_helper = solr_helper
end
|