Sha256: 84d377fa3244302f28f5b42ebeca0c00661a2c399d9872a7c8e53b20155dee28

Contents?: true

Size: 941 Bytes

Versions: 2

Compression:

Stored size: 941 Bytes

Contents

class PageflowPermalinkInput
  include Formtastic::Inputs::Base
  include Formtastic::Inputs::Base::Stringish

  def to_html
    input_wrapping do
      label_html << permalink_html
    end
  end

  private

  def permalink_html
    template.content_tag(
      :div,
      base_url_html << permalink_inputs_html,
      class: 'permalink'
    )
  end

  def base_url_html
    template.content_tag(
      :div,
      options[:base_url].gsub(%r{^https?://}, ''),
      class: 'permalink_base_url'
    )
  end

  def permalink_inputs_html
    return '' if options[:directory_collection].empty?

    builder.select(:directory_id, options[:directory_collection]) <<
      builder.text_field(:slug, placeholder: options[:slug_placeholder])
  end

  def error_keys
    [:directory, :slug]
  end

  def wrapper_html_options
    if options[:directory_collection].empty?
      super.merge(style: 'display: none')
    else
      super
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pageflow-16.0.0 app/inputs/pageflow_permalink_input.rb
pageflow-15.8.0 app/inputs/pageflow_permalink_input.rb