Class: Search::OpportunityPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::OpportunityPresenter
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/opportunity_presenter.rb
Overview
HTML presenter for opportunity search results backed by ViewOpportunity.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#close_date ⇒ String
Returns the close date formatted for display.
-
#contact_button ⇒ ActiveSupport::SafeBuffer
Returns a dropdown of callable contact point dial links.
-
#contact_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated contact, if available.
-
#customer_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the associated customer.
-
#distance ⇒ String?
Returns the distance formatted with a "mi" suffix, if present.
-
#last_sales_activity_completed_on ⇒ String
Returns the last completed sales activity date formatted for display.
-
#next_sales_activity ⇒ ActiveSupport::SafeBuffer?
Returns a button popover with details of the next sales activity, if any.
-
#notes_indicator ⇒ ActiveSupport::SafeBuffer
Returns a notes popover for the last activity notes.
-
#opportunity_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the opportunity.
-
#opportunity_type ⇒ String
Returns the human-readable opportunity type label.
-
#participants_combo ⇒ ActiveSupport::SafeBuffer
Returns an unordered list of links to opportunity participants.
-
#planned_installation_date ⇒ String
Returns the planned installation date formatted for display.
-
#state ⇒ String
Returns the human-readable state name.
-
#value ⇒ String
Returns the opportunity value formatted as currency.
-
#won_lost_date ⇒ String
Returns the won/lost date formatted for display.
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
#close_date ⇒ String
Returns the close date formatted for display.
52 53 54 |
# File 'app/presenters/search/opportunity_presenter.rb', line 52 def close_date h.render_date r.close_date end |
#contact_button ⇒ ActiveSupport::SafeBuffer
Returns a dropdown of callable contact point dial links.
103 104 105 106 |
# File 'app/presenters/search/opportunity_presenter.rb', line 103 def list = r.callable_contact_points_array.map { |cp| h.sip_dial_link(h.number_to_phone(cp.detail), cp.detail, party_id: cp.party_id) } h.render_simple_drop_down list, main_link_class: 'btn-link' end |
#contact_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated contact, if available.
29 30 31 32 33 |
# File 'app/presenters/search/opportunity_presenter.rb', line 29 def contact_link return unless r.has_columns?(:contact_id, :contact_full_name) h.link_to r.contact_full_name, h.contact_path(r.contact_id) end |
#customer_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the associated customer.
22 23 24 |
# File 'app/presenters/search/opportunity_presenter.rb', line 22 def customer_link h.link_to r.customer_full_name, h.customer_path(r.customer_id) end |
#distance ⇒ String?
Returns the distance formatted with a "mi" suffix, if present.
80 81 82 83 84 |
# File 'app/presenters/search/opportunity_presenter.rb', line 80 def distance return unless r.has_columns?(:distance) "#{r.distance.round(2)} mi" end |
#last_sales_activity_completed_on ⇒ String
Returns the last completed sales activity date formatted for display.
45 46 47 |
# File 'app/presenters/search/opportunity_presenter.rb', line 45 def last_sales_activity_completed_on h.render_date r.last_sales_activity_completed_on end |
#next_sales_activity ⇒ ActiveSupport::SafeBuffer?
Returns a button popover with details of the next sales activity, if any.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'app/presenters/search/opportunity_presenter.rb', line 111 def next_sales_activity return unless r.has_columns?(:next_sales_activity_id) && r.next_sales_activity_id && (a = Activity.find(r.next_sales_activity_id)) activity_summary = [] activity_summary << h.content_tag(:p, "Due Date: #{a.target_datetime.to_date}") activity_summary << h.content_tag(:p, "Assigned to: #{a.assigned_resource&.full_name}") activity_summary << h.content_tag(:p, "Notes: #{a.notes}") if a.notes.present? activity_summary << h.link_to(h.fa_icon('external-link', text: 'Open Activity'), h.activity_path(a)) h.(type: 'button', class: 'btn btn-outline-primary', title: 'Open Sales Activity Details', 'data-bs-html': true, 'data-bs-container': 'body', 'data-bs-toggle': 'popover', 'data-bs-content': activity_summary.join.html_safe) do a.display_type end end |
#notes_indicator ⇒ ActiveSupport::SafeBuffer
Returns a notes popover for the last activity notes.
38 39 40 |
# File 'app/presenters/search/opportunity_presenter.rb', line 38 def notes_indicator h.notes_popover r.last_activity_notes end |
#opportunity_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the opportunity.
15 16 17 |
# File 'app/presenters/search/opportunity_presenter.rb', line 15 def opportunity_link h.link_to r.name, h.opportunity_path(r.id) end |
#opportunity_type ⇒ String
Returns the human-readable opportunity type label.
66 67 68 |
# File 'app/presenters/search/opportunity_presenter.rb', line 66 def opportunity_type OpportunityConstants::OPPORTUNITY_TYPES[r.opportunity_type] || 'unknown' end |
#participants_combo ⇒ ActiveSupport::SafeBuffer
Returns an unordered list of links to opportunity participants.
133 134 135 136 137 138 139 140 141 |
# File 'app/presenters/search/opportunity_presenter.rb', line 133 def participants_combo h.content_tag :ul, class: 'list-unstyled' do h.concat(h.content_tag(:li, h.link_to(h.fa_icon('industry', text: r.customer_full_name), h.customer_path(r.customer_id)), style: 'margin-bottom: 5px')) if r.customer_id h.concat(h.content_tag(:li, h.link_to(h.fa_icon('user', text: r.contact_full_name), h.contact_path(r.contact_id)), style: 'margin-bottom: 5px')) if r.contact_id r.opportunity.opportunity_participants.each do |op| h.concat(h.content_tag(:li, h.link_to(h.fa_icon('user', text: op.party.full_name), h.polymorphic_path(op.party)), style: 'margin-bottom: 5px')) end end end |
#planned_installation_date ⇒ String
Returns the planned installation date formatted for display.
89 90 91 |
# File 'app/presenters/search/opportunity_presenter.rb', line 89 def planned_installation_date h.render_date r.planned_installation_date end |
#state ⇒ String
Returns the human-readable state name.
59 60 61 |
# File 'app/presenters/search/opportunity_presenter.rb', line 59 def state Opportunity.human_state_name(r.state) end |
#value ⇒ String
Returns the opportunity value formatted as currency.
73 74 75 |
# File 'app/presenters/search/opportunity_presenter.rb', line 73 def value h.number_to_currency(r.value) end |
#won_lost_date ⇒ String
Returns the won/lost date formatted for display.
96 97 98 |
# File 'app/presenters/search/opportunity_presenter.rb', line 96 def won_lost_date h.render_date r.won_lost_date end |