Sha256: 02b679657043dfcdbb642523274a010403b4843015c868cdded1ff2544441509

Contents?: true

Size: 1.85 KB

Versions: 28

Compression:

Stored size: 1.85 KB

Contents

module PeopleHelper  
  def link_to_person(person)
    case person.type
    when Individual
      link_to person, individual_path(person)
    when Company
      link_to person, company_path(person)
    else
      link_to person, person
    end
  end

  def person_avatar_with_fallback(person, size=50)
    # In development the default image will never appear.
    # (the url has to be publicly available in order for gravatar to fall back to it)
    # If you just want to see the default you can use 
    # image_tag('person-default-avatar.png')
    case person.type
    when "Individual"
      gravatar_image_tag(person.email, :alt => person.to_s, :gravatar => { :secure => true, :size => size, :default => full_image_url('person-default-avatar.png') })
    when "Company"
      image_tag(full_image_url("#{person.subtype.downcase}-default-avatar.png"))
    else
      image_tag(full_image_url('person-default-avatar.png'))
    end

  end

  def full_url(address, protocol='http://')
    if address.include?(protocol)
      address
    else
      "#{protocol}#{address}".squish
    end
  end

  def show_action_template(action)
    if lookup_context.exists?("show", "actions/#{action.action_type.downcase}", true)
      "actions/#{action.action_type.downcase}/show"
    else
      "actions/shared/show"
    end
  end

  def full_image_url(image)
    URI.join(root_url, image_path(image)).to_s
  end

  def action_type_button(action, type, verb, placeholder)
    classes = ['btn', 'action-type-button']
    classes << type
    classes << 'active' if action.action_type.downcase == type rescue nil
    content_tag(
      :button,
      content_tag(:span, verb.capitalize, :class => "#{type}-icon"),
      {:class => classes.join(' '), :type => 'button', 'data-action-type' => type, 'data-details-placeholder' => placeholder, 'data-subtypes' => Action.subtypes_by_type[type].to_json}
    )
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
artfully_ose-1.2.0 app/helpers/people_helper.rb
artfully_ose-1.2.0.beta.1 app/helpers/people_helper.rb
artfully_ose-1.2.0.alpha.2 app/helpers/people_helper.rb
artfully_ose-1.2.0.alpha.1 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.27 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.26 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.24 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.23 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.21 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.20 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.19 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.18 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.17 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.16 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.15 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.12 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.11 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.10 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.9 app/helpers/people_helper.rb
artfully_ose-1.2.0.pre.8 app/helpers/people_helper.rb