Class: Search::LocatorRecordPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::LocatorRecordPresenter
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/locator_record_presenter.rb
Overview
HTML presenter for locator-record search results backed by ViewLocatorRecord.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#confirmed_at ⇒ String
Returns the confirmation date formatted for display.
-
#customer_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the associated customer.
-
#distance ⇒ String
Returns the distance formatted with a "mi." suffix.
-
#features ⇒ String
Returns a comma-separated list of feature labels for the record.
-
#full_address ⇒ ActiveSupport::SafeBuffer
Returns the full address as an HTML paragraph with line breaks.
-
#is_inactive ⇒ ActiveSupport::SafeBuffer
Returns a yes/no indicator for the record's inactive flag.
-
#star_status_level ⇒ ActiveSupport::SafeBuffer
Returns the star status level rendered as gold star icons.
-
#state ⇒ String
Returns the human-readable state name.
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
#confirmed_at ⇒ String
Returns the confirmation date formatted for display.
74 75 76 |
# File 'app/presenters/search/locator_record_presenter.rb', line 74 def confirmed_at h.render_date r.confirmed_at end |
#customer_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the associated customer.
29 30 31 |
# File 'app/presenters/search/locator_record_presenter.rb', line 29 def customer_link h.link_to(r.customer_name, h.customer_path(r.customer_id)) end |
#distance ⇒ String
Returns the distance formatted with a "mi." suffix.
36 37 38 |
# File 'app/presenters/search/locator_record_presenter.rb', line 36 def distance "#{r.distance.to_f.round(2)} mi." end |
#features ⇒ String
Returns a comma-separated list of feature labels for the record.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/presenters/search/locator_record_presenter.rb', line 43 def features feats = [] feats << "Retailer" if r.is_retailer feats << "Installer" if r.is_installer feats << "Electrician" if r.is_electrician feats << "Remodeller/Contractor" if r.is_remodel_contractor feats << "Maintains WY Stock" if r.maintains_wy_stock feats << "Has WY In Floor Display" if r.has_in_floor_display feats << "Has WY Countertop Display" if r.has_countertop_display feats << "Has WY Marketing Materials" if r.has_marketing_materials feats << "Has had WY Visit on #{h.render_date(r.date_of_wy_visit)}" if r.has_had_wy_visit feats << "Supports Flooring" if r.supports_flooring feats << "Supports Snow Melting" if r.supports_snowmelting feats << "Supports Roof Deicing" if r.supports_roof_deicing feats << "Supports Comfort Products" if r.supports_comfort_products feats.join(', ') end |
#full_address ⇒ ActiveSupport::SafeBuffer
Returns the full address as an HTML paragraph with line breaks.
81 82 83 84 85 86 87 |
# File 'app/presenters/search/locator_record_presenter.rb', line 81 def full_address address = [] address << r.street1 if r.has_columns?(:street1) address << r.street2 if r.has_columns?(:street2) address << "#{r.city}, #{r.state_code} #{r.zip}" if r.has_columns?(:city, :state_code, :zip) content_tag(:p, address.filter_map(&:presence).join("<br>").html_safe, class: 'text-nowrap') end |
#is_inactive ⇒ ActiveSupport::SafeBuffer
Returns a yes/no indicator for the record's inactive flag.
15 16 17 |
# File 'app/presenters/search/locator_record_presenter.rb', line 15 def is_inactive h.y r.is_inactive end |
#star_status_level ⇒ ActiveSupport::SafeBuffer
Returns the star status level rendered as gold star icons.
64 65 66 67 68 69 |
# File 'app/presenters/search/locator_record_presenter.rb', line 64 def star_status_level status = r.star_status_level || 0 h.capture do status.times { h.concat h.fa_icon('star', style: 'color: gold') } end end |
#state ⇒ String
Returns the human-readable state name.
22 23 24 |
# File 'app/presenters/search/locator_record_presenter.rb', line 22 def state LocatorRecord.human_state_name(r.state) end |