Class: Tramway::Landing::BlockDecorator
- Inherits:
-
Core::ApplicationDecorator
- Object
- Core::ApplicationDecorator
- Tramway::Landing::BlockDecorator
- Defined in:
- app/decorators/tramway/landing/block_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #block_type ⇒ Object
- #button ⇒ Object
- #link ⇒ Object
- #page_title ⇒ Object
- #public_path ⇒ Object
- #view_state ⇒ Object
- #view_state_button_color(event) ⇒ Object
Class Method Details
.collections ⇒ Object
5 6 7 |
# File 'app/decorators/tramway/landing/block_decorator.rb', line 5 def collections [:all] end |
.list_attributes ⇒ Object
9 10 11 |
# File 'app/decorators/tramway/landing/block_decorator.rb', line 9 def list_attributes %i[page_title position view_state block_type] end |
.show_associations ⇒ Object
13 14 15 |
# File 'app/decorators/tramway/landing/block_decorator.rb', line 13 def show_associations [:forms] end |
Instance Method Details
#block_type ⇒ Object
35 36 37 |
# File 'app/decorators/tramway/landing/block_decorator.rb', line 35 def block_type object.block_type_text end |
#button ⇒ Object
56 57 58 59 60 61 62 |
# File 'app/decorators/tramway/landing/block_decorator.rb', line 56 def if object..present? && object.['button_title'].present? && object.['button_link'].present? content_tag :a, href: object.['button_link'], target: '_blank', class: 'btn btn-primary' do object.['button_title'] end end end |
#link ⇒ Object
43 44 45 |
# File 'app/decorators/tramway/landing/block_decorator.rb', line 43 def link "##{object.anchor}" end |
#page_title ⇒ Object
31 32 33 |
# File 'app/decorators/tramway/landing/block_decorator.rb', line 31 def page_title object.page&.title end |
#public_path ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/decorators/tramway/landing/block_decorator.rb', line 23 def public_path if object.published? Tramway::Page::Engine.routes.url_helpers.page_path slug: object.page.slug if object.page.slug.present? else Tramway::Page::Engine.routes.url_helpers.preview_path id: object.page.id end end |
#view_state ⇒ Object
39 40 41 |
# File 'app/decorators/tramway/landing/block_decorator.rb', line 39 def view_state object.view_state end |
#view_state_button_color(event) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'app/decorators/tramway/landing/block_decorator.rb', line 47 def (event) case event when :publish :primary when :hide :secondary end end |