Sha256: e1d9a001db5822755376dc2c450e156a163321a5134f99fdebaaf7dc570a7983

Contents?: true

Size: 1.03 KB

Versions: 18

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

class Tramway::Landing::BlockDecorator < ::Tramway::Core::ApplicationDecorator
  class << self
    def collections
      [:all]
    end

    def list_attributes
      %i[position view_state block_type]
    end

    delegate :human_view_state_event_name, to: :model_class
  end

  delegate :position, to: :object
  delegate :title, to: :object
  delegate :background, to: :object
  delegate :anchor, to: :object
  delegate :description, to: :object
  delegate :anchor, to: :object
  delegate :view_name, to: :object

  def block_type
    object.block_type_text
  end

  def view_state
    object.human_view_state_name
  end

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

  def button
    if object.button.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
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
tramway-landing-2.0.0.1 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-2.0 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.3.3 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.3.2 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.3.1 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.3 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.2.8 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.2.7 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.2.6 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.2.5 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.2.4 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.2.3 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.2.2 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.2.1 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.2 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.1.2 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.1.1 app/decorators/tramway/landing/block_decorator.rb
tramway-landing-1.8.1 app/decorators/tramway/landing/block_decorator.rb