Class: Search::ContactPresenter

Inherits:
BasePresenter show all
Includes:
Presenters::Timeable
Defined in:
app/presenters/search/contact_presenter.rb

Overview

Row presenter for ViewContact — renders the cells in the CRM contact
search/results table.

Direct Known Subclasses

ContactTextPresenter

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_account, #options, #url_helper

Instance Method Summary collapse

Methods inherited from BasePresenter

#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u

Constructor Details

This class inherits a constructor from BasePresenter

Instance Method Details

#contactActiveSupport::SafeBuffer?

Linked contact name → contact show page.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


13
14
15
16
17
# File 'app/presenters/search/contact_presenter.rb', line 13

def contact
  return unless r.has_columns?(:id, :full_name) && r.id && r.full_name

  h.link_to r.full_name, h.contact_path(r.id)
end

#contact_rolesString?

Human-readable, comma-separated list of the contact's roles.

Returns:

  • (String, nil)


31
32
33
34
35
# File 'app/presenters/search/contact_presenter.rb', line 31

def contact_roles
  return unless r.has_columns?(:contact_roles) && r.contact_roles.present?

  (r.contact_roles || []).filter_map(&:presence).map(&:titleize).try(:to_sentence)
end

#customerActiveSupport::SafeBuffer?

Linked customer name → customer show page.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


22
23
24
25
26
# File 'app/presenters/search/contact_presenter.rb', line 22

def customer
  return unless r.has_columns?(:customer_id, :customer_full_name) && r.customer_id && r.customer_full_name

  h.link_to r.customer_full_name, h.customer_path(r.customer_id)
end

#primary_faxActiveSupport::SafeBuffer?

Primary fax number formatted for domestic display.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


49
50
51
52
53
# File 'app/presenters/search/contact_presenter.rb', line 49

def primary_fax
  return unless r.has_columns?(:primary_fax) && r.primary_fax.present?

  h.number_to_phone(r.primary_fax)
end

#primary_fax_internationalString?

Raw primary fax number (international formatting preserved).

Returns:

  • (String, nil)


67
68
69
70
71
# File 'app/presenters/search/contact_presenter.rb', line 67

def primary_fax_international
  return unless r.has_columns?(:primary_fax) && r.primary_fax.present?

  r.primary_fax
end

#primary_phoneActiveSupport::SafeBuffer?

Primary phone number formatted for domestic display.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


40
41
42
43
44
# File 'app/presenters/search/contact_presenter.rb', line 40

def primary_phone
  return unless r.has_columns?(:primary_phone) && r.primary_phone.present?

  h.number_to_phone(r.primary_phone)
end

#primary_phone_internationalString?

Raw primary phone number (international formatting preserved).

Returns:

  • (String, nil)


58
59
60
61
62
# File 'app/presenters/search/contact_presenter.rb', line 58

def primary_phone_international
  return unless r.has_columns?(:primary_phone) && r.primary_phone.present?

  r.primary_phone
end