Module: PeopleHelper
- Defined in:
- app/helpers/people_helper.rb
Instance Method Summary collapse
- #action_type_button(action, type, verb, placeholder) ⇒ Object
- #full_image_url(image) ⇒ Object
- #full_url(address, protocol = 'http://') ⇒ Object
- #link_to_person(person) ⇒ Object
- #person_avatar_with_fallback(person, size = 50) ⇒ Object
- #show_action_template(action) ⇒ Object
Instance Method Details
#action_type_button(action, type, verb, placeholder) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/people_helper.rb', line 49 def (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 |
#full_image_url(image) ⇒ Object
45 46 47 |
# File 'app/helpers/people_helper.rb', line 45 def full_image_url(image) URI.join(root_url, image_path(image)).to_s end |
#full_url(address, protocol = 'http://') ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/helpers/people_helper.rb', line 29 def full_url(address, protocol='http://') if address.include?(protocol) address else "#{protocol}#{address}".squish end end |
#link_to_person(person) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'app/helpers/people_helper.rb', line 2 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 |
#person_avatar_with_fallback(person, size = 50) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/people_helper.rb', line 13 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 |
#show_action_template(action) ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/helpers/people_helper.rb', line 37 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 |