Sha256: 03b70a5e07b5ec1058edffba4a85740df57b3e35cb8c5ad3dd4c87b1941470cc

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

class Tramway::Landing::BlockForm < ::Tramway::Core::ExtendedApplicationForm
  properties :title,
    :background,
    :view_state,
    :block_type,
    :position,
    :navbar_link,
    :anchor,
    :description,
    :link_object_type,
    :link_object_id,
    :button_title,
    :button_link,
    :view_name

  def initialize(object = nil)
    super(object).tap do
      form_properties title: :string,
                      background: :file,
                      position: :numeric,
                      block_type: :default,
                      navbar_link: :default,
                      anchor: :string,
                      description: :ckeditor,
                      button_title: :string,
                      button_link: :string
    end
  end

  def button_title
    model.button ||= {}
    model.button['title'] || ''
  end

  def button_link
    model.button ||= {}
    model.button['link'] || ''
  end

  def button_title=(value)
    model.button ||= {}
    model.button[:title] = value
    model.save
  end

  def button_link=(value)
    model.button ||= {}
    model.button[:link] = value
    model.save
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tramway-landing-1.8.1.1 app/forms/tramway/landing/block_form.rb
tramway-landing-1.8.1 app/forms/tramway/landing/block_form.rb