Class: Search::OpportunityPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::OpportunityPresenter
show all
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/opportunity_presenter.rb
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
27
28
29
|
# File 'app/presenters/search/opportunity_presenter.rb', line 27
def close_date
h.render_date r.close_date
end
|
56
57
58
59
|
# File 'app/presenters/search/opportunity_presenter.rb', line 56
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
|
14
15
16
17
|
# File 'app/presenters/search/opportunity_presenter.rb', line 14
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
10
11
12
|
# File 'app/presenters/search/opportunity_presenter.rb', line 10
def customer_link
h.link_to r.customer_full_name, h.customer_path(r.customer_id)
end
|
#distance ⇒ Object
43
44
45
46
|
# File 'app/presenters/search/opportunity_presenter.rb', line 43
def distance
return unless r.has_columns?(:distance)
"#{r.distance.round(2)} mi"
end
|
#last_sales_activity_completed_on ⇒ Object
23
24
25
|
# File 'app/presenters/search/opportunity_presenter.rb', line 23
def last_sales_activity_completed_on
h.render_date r.last_sales_activity_completed_on
end
|
#next_sales_activity ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/presenters/search/opportunity_presenter.rb', line 61
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
19
20
21
|
# File 'app/presenters/search/opportunity_presenter.rb', line 19
def notes_indicator
h.notes_popover r.last_activity_notes
end
|
#opportunity_link ⇒ Object
6
7
8
|
# File 'app/presenters/search/opportunity_presenter.rb', line 6
def opportunity_link
h.link_to r.name, h.opportunity_path(r.id)
end
|
#opportunity_type ⇒ Object
35
36
37
|
# File 'app/presenters/search/opportunity_presenter.rb', line 35
def opportunity_type
OpportunityConstants::OPPORTUNITY_TYPES[r.opportunity_type] || 'unknown'
end
|
#participants_combo ⇒ Object
81
82
83
84
85
86
87
88
89
|
# File 'app/presenters/search/opportunity_presenter.rb', line 81
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
48
49
50
|
# File 'app/presenters/search/opportunity_presenter.rb', line 48
def planned_installation_date
h.render_date r.planned_installation_date
end
|
#state ⇒ Object
31
32
33
|
# File 'app/presenters/search/opportunity_presenter.rb', line 31
def state
Opportunity.human_state_name(r.state)
end
|
#value ⇒ Object
39
40
41
|
# File 'app/presenters/search/opportunity_presenter.rb', line 39
def value
h.number_to_currency(r.value)
end
|
#won_lost_date ⇒ Object
52
53
54
|
# File 'app/presenters/search/opportunity_presenter.rb', line 52
def won_lost_date
h.render_date r.won_lost_date
end
|