Class: Search::LocatorRecordPresenter

Inherits:
BasePresenter
  • Object
show all
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

LocatorRecordTextPresenter

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

#confirmed_atString

Returns the confirmation date formatted for display.

Returns:

  • (String)


74
75
76
# File 'app/presenters/search/locator_record_presenter.rb', line 74

def confirmed_at
  h.render_date r.confirmed_at
end

Returns a link to the associated customer.

Returns:

  • (ActiveSupport::SafeBuffer)


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

#distanceString

Returns the distance formatted with a "mi." suffix.

Returns:

  • (String)


36
37
38
# File 'app/presenters/search/locator_record_presenter.rb', line 36

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

#featuresString

Returns a comma-separated list of feature labels for the record.

Returns:

  • (String)


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_addressActiveSupport::SafeBuffer

Returns the full address as an HTML paragraph with line breaks.

Returns:

  • (ActiveSupport::SafeBuffer)


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)
  (:p, address.filter_map(&:presence).join("<br>").html_safe, class: 'text-nowrap')
end

#is_inactiveActiveSupport::SafeBuffer

Returns a yes/no indicator for the record's inactive flag.

Returns:

  • (ActiveSupport::SafeBuffer)


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

def is_inactive
  h.y r.is_inactive
end

#star_status_levelActiveSupport::SafeBuffer

Returns the star status level rendered as gold star icons.

Returns:

  • (ActiveSupport::SafeBuffer)


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

#stateString

Returns the human-readable state name.

Returns:

  • (String)


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

def state
  LocatorRecord.human_state_name(r.state)
end