Class: Tramway::Landing::BlockDecorator

Inherits:
Core::ApplicationDecorator
  • Object
show all
Defined in:
app/decorators/tramway/landing/block_decorator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.collectionsObject



5
6
7
# File 'app/decorators/tramway/landing/block_decorator.rb', line 5

def collections
  [:all]
end

.list_attributesObject



9
10
11
# File 'app/decorators/tramway/landing/block_decorator.rb', line 9

def list_attributes
  %i[position view_state block_type]
end

Instance Method Details

#block_typeObject



18
19
20
# File 'app/decorators/tramway/landing/block_decorator.rb', line 18

def block_type
  object.block_type_text
end

#buttonObject



43
44
45
46
47
48
49
# File 'app/decorators/tramway/landing/block_decorator.rb', line 43

def button
  if object.button.present? && object.button['title'].present? && object.button['link'].present?
     :a, href: object.button['link'], target: '_blank', class: 'btn btn-primary' do
      object.button['title']
    end
  end
end

#form_urlObject



30
31
32
# File 'app/decorators/tramway/landing/block_decorator.rb', line 30

def form_url
  object.values['form_url']
end


26
27
28
# File 'app/decorators/tramway/landing/block_decorator.rb', line 26

def link
  "##{object.anchor}"
end

#view_stateObject



22
23
24
# File 'app/decorators/tramway/landing/block_decorator.rb', line 22

def view_state
  object.human_view_state_name
end

#view_state_button_color(event) ⇒ Object



34
35
36
37
38
39
40
41
# File 'app/decorators/tramway/landing/block_decorator.rb', line 34

def view_state_button_color(event)
  case event
  when :publish
    :primary
  when :hide
    :secondary
  end
end