Class: Search::CustomerPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::CustomerPresenter
- 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
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#affiliations ⇒ ActiveSupport::SafeBuffer?
Customer affiliations rendered as an unstyled HTML list.
-
#creation_method ⇒ String?
Human-readable creation method label.
-
#customer ⇒ ActiveSupport::SafeBuffer
Linked customer full name → customer show page.
-
#customer_main_fax ⇒ String
Customer main fax formatted for display.
-
#customer_main_fax_international ⇒ String?
Raw customer main fax value when the column is selected.
-
#customer_main_phone ⇒ String
Customer main phone formatted for display.
-
#customer_main_phone_international ⇒ String?
Raw customer main phone value when the column is selected.
-
#customer_watch_symbol ⇒ ActiveSupport::SafeBuffer?
Visual watch indicator for the customer, or nil when the search row does not include the required columns.
-
#distance ⇒ String?
Distance in miles, rounded to two decimals.
-
#drop_reasons ⇒ ActiveSupport::SafeBuffer
Drop reasons rendered as an unstyled HTML list.
-
#floor_types_interest_last_2_years ⇒ ActiveSupport::SafeBuffer?
Floor types of interest over the last two years as an unstyled list.
-
#has_online_account ⇒ ActiveSupport::SafeBuffer
Y/ blank indicator for online account status. -
#id ⇒ ActiveSupport::SafeBuffer
Linked customer number (
CN<id>) → customer show page. -
#last_order_date ⇒ String
Last order date rendered through the shared date helper.
-
#last_quote_date ⇒ String
Last quote date rendered through the shared date helper.
-
#lifetime_revenue ⇒ String
Lifetime revenue formatted as currency.
-
#open_sales_activity ⇒ ActiveSupport::SafeBuffer
Y/ blank indicator for open sales activity. -
#profiling_data_last_edited_at ⇒ String
Profiling data last edited date rendered through the shared date helper.
-
#rating ⇒ ActiveSupport::SafeBuffer?
Rating value wrapped in a span with the rating as a CSS class.
-
#room_types_interest_last_2_years ⇒ ActiveSupport::SafeBuffer?
Room types of interest over the last two years as an unstyled list.
-
#trailing_twelve_months_revenue ⇒ String
Trailing twelve months revenue formatted as currency.
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
#affiliations ⇒ ActiveSupport::SafeBuffer?
Customer affiliations rendered as an unstyled HTML list.
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_method ⇒ String?
Human-readable creation method label.
29 30 31 |
# File 'app/presenters/search/customer_presenter.rb', line 29 def creation_method Customer.creation_methods.invert[r.creation_method] end |
#customer ⇒ ActiveSupport::SafeBuffer
Linked customer full name → customer show page.
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_fax ⇒ String
Customer main fax formatted for display.
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_international ⇒ String?
Raw customer main fax value when the column is selected.
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_phone ⇒ String
Customer main phone formatted for display.
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_international ⇒ String?
Raw customer main phone value when the column is selected.
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_symbol ⇒ ActiveSupport::SafeBuffer?
Visual watch indicator for the customer, or nil when the search row
does not include the required columns.
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 |
#distance ⇒ String?
Distance in miles, rounded to two decimals.
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_reasons ⇒ ActiveSupport::SafeBuffer
Drop reasons rendered as an unstyled HTML list.
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_years ⇒ ActiveSupport::SafeBuffer?
Floor types of interest over the last two years as an unstyled list.
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_account ⇒ ActiveSupport::SafeBuffer
Y / blank indicator for online account status.
53 54 55 |
# File 'app/presenters/search/customer_presenter.rb', line 53 def has_online_account h.y r.has_online_account end |
#id ⇒ ActiveSupport::SafeBuffer
Linked customer number (CN<id>) → customer show page.
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_date ⇒ String
Last order date rendered through the shared date helper.
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_date ⇒ String
Last quote date rendered through the shared date helper.
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_revenue ⇒ String
Lifetime revenue formatted as currency.
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_activity ⇒ ActiveSupport::SafeBuffer
Y / blank indicator for open sales activity.
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_at ⇒ String
Profiling data last edited date rendered through the shared date helper.
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 |
#rating ⇒ ActiveSupport::SafeBuffer?
Rating value wrapped in a span with the rating as a CSS class.
60 61 62 |
# File 'app/presenters/search/customer_presenter.rb', line 60 def h.content_tag(:span, r., id: 'customerrank', class: r.) if r. end |
#room_types_interest_last_2_years ⇒ ActiveSupport::SafeBuffer?
Room types of interest over the last two years as an unstyled list.
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_revenue ⇒ String
Trailing twelve months revenue formatted as currency.
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 |