Class: SirTrevorRails::Blocks::FeaturedPagesBlock
- Inherits:
-
SirTrevorRails::Block
- Object
- SirTrevorRails::Block
- SirTrevorRails::Blocks::FeaturedPagesBlock
show all
- Includes:
- Displayable
- Defined in:
- app/models/sir_trevor_rails/blocks/featured_pages_block.rb
Overview
Multi-up featured page block
Instance Method Summary
collapse
#item_ids, #items, #ordered_items
Instance Method Details
#as_json ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/models/sir_trevor_rails/blocks/featured_pages_block.rb', line 22
def as_json
result = super
result[:data][:item] ||= {}
result[:data][:item].each_value do |v|
v['thumbnail_image_url'] = parent.exhibit.pages.find(v['id']).thumbnail_image_url
end
result
end
|
#page_options(id) ⇒ Object
8
9
10
|
# File 'app/models/sir_trevor_rails/blocks/featured_pages_block.rb', line 8
def page_options(id)
(items.detect { |x| x[:id] == id }) || {}
end
|
#pages ⇒ Object
12
13
14
15
16
|
# File 'app/models/sir_trevor_rails/blocks/featured_pages_block.rb', line 12
def pages
@pages ||= parent.exhibit.pages.published.where(slug: item_ids).sort do |a, b|
ordered_items.index(a.slug) <=> ordered_items.index(b.slug)
end
end
|
#pages? ⇒ Boolean
18
19
20
|
# File 'app/models/sir_trevor_rails/blocks/featured_pages_block.rb', line 18
def pages?
!pages.empty?
end
|