Class: Search::OpportunityPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::OpportunityPresenter
show all
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/opportunity_presenter.rb
Overview
Presenter: opportunity presenter.
Instance Attribute Summary
#current_account, #options, #url_helper
Instance Method Summary
collapse
#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 ⇒ Object
30
31
32
|
# File 'app/presenters/search/opportunity_presenter.rb', line 30
def close_date
h.render_date r.close_date
end
|
60
61
62
63
|
# File 'app/presenters/search/opportunity_presenter.rb', line 60
def contact_button
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
|
16
17
18
19
20
|
# File 'app/presenters/search/opportunity_presenter.rb', line 16
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 ⇒ Object
12
13
14
|
# File 'app/presenters/search/opportunity_presenter.rb', line 12
def customer_link
h.link_to r.customer_full_name, h.customer_path(r.customer_id)
end
|
#distance ⇒ Object
46
47
48
49
50
|
# File 'app/presenters/search/opportunity_presenter.rb', line 46
def distance
return unless r.has_columns?(:distance)
"#{r.distance.round(2)} mi"
end
|
#last_sales_activity_completed_on ⇒ Object
26
27
28
|
# File 'app/presenters/search/opportunity_presenter.rb', line 26
def last_sales_activity_completed_on
h.render_date r.last_sales_activity_completed_on
end
|
#next_sales_activity ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'app/presenters/search/opportunity_presenter.rb', line 65
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.button_tag(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 ⇒ Object
22
23
24
|
# File 'app/presenters/search/opportunity_presenter.rb', line 22
def notes_indicator
h.notes_popover r.last_activity_notes
end
|
#opportunity_link ⇒ Object
8
9
10
|
# File 'app/presenters/search/opportunity_presenter.rb', line 8
def opportunity_link
h.link_to r.name, h.opportunity_path(r.id)
end
|
#opportunity_type ⇒ Object
38
39
40
|
# File 'app/presenters/search/opportunity_presenter.rb', line 38
def opportunity_type
OpportunityConstants::OPPORTUNITY_TYPES[r.opportunity_type] || 'unknown'
end
|
#participants_combo ⇒ Object
84
85
86
87
88
89
90
91
92
|
# File 'app/presenters/search/opportunity_presenter.rb', line 84
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 ⇒ Object
52
53
54
|
# File 'app/presenters/search/opportunity_presenter.rb', line 52
def planned_installation_date
h.render_date r.planned_installation_date
end
|
#state ⇒ Object
34
35
36
|
# File 'app/presenters/search/opportunity_presenter.rb', line 34
def state
Opportunity.human_state_name(r.state)
end
|
#value ⇒ Object
42
43
44
|
# File 'app/presenters/search/opportunity_presenter.rb', line 42
def value
h.number_to_currency(r.value)
end
|
#won_lost_date ⇒ Object
56
57
58
|
# File 'app/presenters/search/opportunity_presenter.rb', line 56
def won_lost_date
h.render_date r.won_lost_date
end
|