Sha256: 280406c797db508a82bacc66305fea4e6fa7622983569d08f9f37d6e283d4b30

Contents?: true

Size: 919 Bytes

Versions: 14

Compression:

Stored size: 919 Bytes

Contents

class C2::Informant::FormElement
  include Mongoid::Document
  
  field :tag
  field :name
  field :caption
  field :tip
  
  field :enabled, :type => Boolean, :default => true
  
  embedded_in :locus, :class_name => 'C2::Informant::Locus'
  
  scope :enabled, :where => { :enabled => true }
  
  delegate :klass, :to => :'_parent'
  
  def as_json(options={})
    {
      'type' => 'div',
      'id' => "entry_#{name}_field",
      'class' => "field #{name}_field #{tag}",
      'elements' => [
        {
          'type' => tag,
          'name' => name,
          'id' => "entry_#{name}",
          'class' => "#{name}_input #{tag}",
          'caption' => (caption || name.titleize)
        },
        {
          'type' => 'div',
          'class' => 'tip',
          'elements' => [
            {
              'type' => 'p',
              'html' => tip
            }
          ]
        }
      ]
    }
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
c2-0.1.13 app/models/c2/informant/form_element.rb
c2-0.1.12 app/models/c2/informant/form_element.rb
c2-0.1.11 app/models/c2/informant/form_element.rb
c2-0.1.10 app/models/c2/informant/form_element.rb
c2-0.1.9 app/models/c2/informant/form_element.rb
c2-0.1.8 app/models/c2/informant/form_element.rb
c2-0.1.7 app/models/c2/informant/form_element.rb
c2-0.1.6 app/models/c2/informant/form_element.rb
c2-0.1.5 app/models/c2/informant/form_element.rb
c2-0.1.4 app/models/c2/informant/form_element.rb
c2-0.1.3 app/models/c2/informant/form_element.rb
c2-0.1.2 app/models/c2/informant/form_element.rb
c2-0.1.1 app/models/c2/informant/form_element.rb
c2-0.1.0 app/models/c2/informant/form_element.rb