Class: Search::CustomerPresenter

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

Overview

Renders CRM customer search result rows as HTML cells.

Wraps a ViewCustomer projection and produces links, formatted
currency/phone values, and yes/no indicators for the search grid.

Direct Known Subclasses

CustomerTextPresenter

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

#affiliationsActiveSupport::SafeBuffer?

Customer affiliations rendered as an unstyled HTML list.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


159
160
161
162
163
# File 'app/presenters/search/customer_presenter.rb', line 159

def affiliations
  return unless has_columns?(:affiliations)

  h.array_to_list(r.affiliations, class: 'list-unstyled')
end

#creation_methodString?

Human-readable creation method label.

Returns:

  • (String, nil)


29
30
31
# File 'app/presenters/search/customer_presenter.rb', line 29

def creation_method
  Customer.creation_methods.invert[r.creation_method]
end

#customerActiveSupport::SafeBuffer

Linked customer full name → customer show page.

Returns:

  • (ActiveSupport::SafeBuffer)


15
16
17
# File 'app/presenters/search/customer_presenter.rb', line 15

def customer
  h.link_to r.full_name, h.customer_path(r.id)
end

#customer_main_faxString

Customer main fax formatted for display.

Returns:

  • (String)


83
84
85
# File 'app/presenters/search/customer_presenter.rb', line 83

def customer_main_fax
  h.number_to_phone(r.customer_main_fax)
end

#customer_main_fax_internationalString?

Raw customer main fax value when the column is selected.

Returns:

  • (String, nil)


90
91
92
93
94
# File 'app/presenters/search/customer_presenter.rb', line 90

def customer_main_fax_international
  return unless r.has_columns?(:customer_main_fax)

  r.customer_main_fax
end

#customer_main_phoneString

Customer main phone formatted for display.

Returns:

  • (String)


67
68
69
# File 'app/presenters/search/customer_presenter.rb', line 67

def customer_main_phone
  h.number_to_phone(r.customer_main_phone)
end

#customer_main_phone_internationalString?

Raw customer main phone value when the column is selected.

Returns:

  • (String, nil)


74
75
76
77
78
# File 'app/presenters/search/customer_presenter.rb', line 74

def customer_main_phone_international
  return unless r.has_columns?(:customer_main_phone)

  r.customer_main_phone
end

#customer_watch_symbolActiveSupport::SafeBuffer?

Visual watch indicator for the customer, or nil when the search row
does not include the required columns.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


37
38
39
40
41
# File 'app/presenters/search/customer_presenter.rb', line 37

def customer_watch_symbol
  return unless r.has_columns?(:watch, :open_sales_activity)

  h.concat h.customer_watch_symbol_raw(r.watch, r.open_sales_activity)
end

#distanceString?

Distance in miles, rounded to two decimals.

Returns:

  • (String, nil)


168
169
170
171
172
# File 'app/presenters/search/customer_presenter.rb', line 168

def distance
  return unless has_columns?(:distance)

  "#{r.distance.to_f.round(2)} mi."
end

#drop_reasonsActiveSupport::SafeBuffer

Drop reasons rendered as an unstyled HTML list.

Returns:

  • (ActiveSupport::SafeBuffer)


99
100
101
# File 'app/presenters/search/customer_presenter.rb', line 99

def drop_reasons
  h.array_to_list(r.drop_reasons, class: 'list-unstyled')
end

#floor_types_interest_last_2_yearsActiveSupport::SafeBuffer?

Floor types of interest over the last two years as an unstyled list.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


141
142
143
144
145
# File 'app/presenters/search/customer_presenter.rb', line 141

def floor_types_interest_last_2_years
  return unless has_columns?(:floor_types_interest_last_2_years)

  h.array_to_list(r.floor_types_interest_last_2_years.map { |ftid| FloorType.find(ftid).name }, class: 'list-unstyled')
end

#has_online_accountActiveSupport::SafeBuffer

Y / blank indicator for online account status.

Returns:

  • (ActiveSupport::SafeBuffer)


53
54
55
# File 'app/presenters/search/customer_presenter.rb', line 53

def 
  h.y r.
end

#idActiveSupport::SafeBuffer

Linked customer number (CN<id>) → customer show page.

Returns:

  • (ActiveSupport::SafeBuffer)


22
23
24
# File 'app/presenters/search/customer_presenter.rb', line 22

def id
  h.link_to "CN#{r.id}", h.customer_path(r.id)
end

#last_order_dateString

Last order date rendered through the shared date helper.

Returns:

  • (String)


120
121
122
# File 'app/presenters/search/customer_presenter.rb', line 120

def last_order_date
  h.render_date(r.last_order_date)
end

#last_quote_dateString

Last quote date rendered through the shared date helper.

Returns:

  • (String)


127
128
129
# File 'app/presenters/search/customer_presenter.rb', line 127

def last_quote_date
  h.render_date(r.last_quote_date)
end

#lifetime_revenueString

Lifetime revenue formatted as currency.

Returns:

  • (String)


113
114
115
# File 'app/presenters/search/customer_presenter.rb', line 113

def lifetime_revenue
  h.number_to_currency(r.lifetime_revenue)
end

#open_sales_activityActiveSupport::SafeBuffer

Y / blank indicator for open sales activity.

Returns:

  • (ActiveSupport::SafeBuffer)


46
47
48
# File 'app/presenters/search/customer_presenter.rb', line 46

def open_sales_activity
  h.y r.open_sales_activity
end

#profiling_data_last_edited_atString

Profiling data last edited date rendered through the shared date helper.

Returns:

  • (String)


134
135
136
# File 'app/presenters/search/customer_presenter.rb', line 134

def profiling_data_last_edited_at
  h.render_date(r.profiling_data_last_edited_at)
end

#ratingActiveSupport::SafeBuffer?

Rating value wrapped in a span with the rating as a CSS class.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


60
61
62
# File 'app/presenters/search/customer_presenter.rb', line 60

def rating
  h.(:span, r.rating, id: 'customerrank', class: r.rating) if r.rating
end

#room_types_interest_last_2_yearsActiveSupport::SafeBuffer?

Room types of interest over the last two years as an unstyled list.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


150
151
152
153
154
# File 'app/presenters/search/customer_presenter.rb', line 150

def room_types_interest_last_2_years
  return unless has_columns?(:room_types_interest_last_2_years)

  h.array_to_list(r.room_types_interest_last_2_years.map { |rtid| RoomType.find(rtid).name }, class: 'list-unstyled')
end

#trailing_twelve_months_revenueString

Trailing twelve months revenue formatted as currency.

Returns:

  • (String)


106
107
108
# File 'app/presenters/search/customer_presenter.rb', line 106

def trailing_twelve_months_revenue
  h.number_to_currency(r.trailing_twelve_months_revenue)
end