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.0.328.4a753fc app/helpers/rails_connector/default_crm_form_helper.rb
infopark_rails_connector-6.8.0.322.c003f11 app/helpers/rails_connector/default_crm_form_helper.rb