Sha256: 0c2963c61d0037746394a2027fd2e8ceb8c63b87a10918629e4d3130e5611747

Contents?: true

Size: 1.96 KB

Versions: 22

Compression:

Stored size: 1.96 KB

Contents

module RailsConnector

  # @api public
  module DefaultCrmFormHelper

    include ::RailsConnector::DefaultUserHelper
    include ::RailsConnector::MandatoryLabelHelper
    include ::RailsConnector::ErrorMessagesHelper

    # @api public
    def custom_fields_for(form)
      activity = instance_variable_get("@#{form.object_name}")
      custom_attribute_defs = Infopark::Crm::CustomType.find(activity.kind).custom_attributes
      content = "".html_safe
      custom_attribute_defs.each do |attribute|
        custom_attr = "custom_#{attribute.name}"
        next unless allow_custom_attribute?(custom_attr)
        value = activity.__send__(custom_attr).to_s
        input_field =
          case attribute.type
          when 'enum'
            form.select(custom_attr, [''] + attribute.valid_values, :value => value)
          when 'text'
            form.text_area(custom_attr, :value => value, :cols => 50, :rows => 5)
          else
            form.text_field(custom_attr, :value => value, :size => "40")
          end
        content << content_tag(:div, :class => 'label') do
          if attribute.mandatory
            mandatory_label_for(form, custom_attr, h(attribute.title))
          else
            form.label(custom_attr, h(attribute.title))
          end
        end
        content << content_tag(:div, input_field, :class => 'field')
      end
      content
    end

    # @api public
    def title_field_for(form)
      content = "".html_safe
      if has_title_input_field?
        content << content_tag(:div, :class => 'label') do
          mandatory_label_for(form, :title, t(:"rails_connector.views.crm_form.title"))
        end
        content << content_tag(:div, :class => 'field') do
          form.text_field :title
        end
      end
      content
    end

    # @api public
    def logged_in_as(user)
      content_tag(:em) do
        t('rails_connector.views.crm_form.logged_in_as',
            :user => content_tag(:strong, user)).html_safe
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
infopark_rails_connector-6.8.3.174.51542603 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.3.115.227021242 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.3.73.75172665 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.3.2.153416031 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.3.67.110847540 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.3.1.23895778 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.2.36.82613853 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.2.7.128454143 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.1.26.236500544 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.1 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.0.539.93842523 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.0.529.114081979 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.0.518.30999728 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.0.515.34928522 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.0.498.46559598 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.0.480.261594408 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.0.444.171626367 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.0.406.131718077 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.0.356.19698103 app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.0.348.160665197 app/helpers/rails_connector/default_crm_form_helper.rb