Class: Search::ActivityPresenter
- Inherits:
-
BasePresenter
show all
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/activity_presenter.rb
Overview
Presenter: activity 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
#activity_link ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'app/presenters/search/activity_presenter.rb', line 23
def activity_link
css_classes = %w[btn btn-block]
css_classes << if open_activity?
'btn-success'
else
'btn-outline-primary'
end
h.link_to(r.activity_type_task_type, h.activity_path(r.id), class: css_classes.join(' '))
end
|
#assigned_resource ⇒ Object
16
17
18
19
20
21
|
# File 'app/presenters/search/activity_presenter.rb', line 16
def assigned_resource
h.capture do
h.concat h.content_tag :p, r.assigned_resource_full_name, class: ('text-success' if assigned_to_current_user?)
h.concat h.content_tag :del, r.original_assigned_resource_full_name, class: 'text-muted' if r.original_assigned_resource_id && r.assigned_resource_id && original_assigned_resource_id != r.assigned_resource_id
end
end
|
#assigned_to_current_user? ⇒ Boolean
8
9
10
|
# File 'app/presenters/search/activity_presenter.rb', line 8
def assigned_to_current_user?
h.current_user.id == r.assigned_resource_id
end
|
#campaign ⇒ Object
105
106
107
108
109
|
# File 'app/presenters/search/activity_presenter.rb', line 105
def campaign
return unless r.has_columns?(:campaign_id, :campaign_name) && r.campaign_id && r.campaign_name
h.link_to(r.campaign_name, h.campaign_path(r.campaign_id))
end
|
#compact_notes ⇒ Object
123
124
125
126
127
|
# File 'app/presenters/search/activity_presenter.rb', line 123
def compact_notes
cn = r.try(:notes) || r.try(:description)
cn = cn.gsub(/\[.*\]/, '').strip if cn
cn
end
|
#completion_date ⇒ Object
64
65
66
|
# File 'app/presenters/search/activity_presenter.rb', line 64
def completion_date
h.render_date(r.completion_datetime)
end
|
#completion_datetime ⇒ Object
60
61
62
|
# File 'app/presenters/search/activity_presenter.rb', line 60
def completion_datetime
h.render_datetime(r.completion_datetime)
end
|
#completion_time ⇒ Object
68
69
70
|
# File 'app/presenters/search/activity_presenter.rb', line 68
def completion_time
h.render_time(r.completion_datetime)
end
|
99
100
101
102
103
|
# File 'app/presenters/search/activity_presenter.rb', line 99
def contact
return unless r.has_columns?(:contact_id, :contact_full_name) && r.contact_id && r.contact_full_name
h.link_to(r.contact_full_name, h.contact_path(r.contact_id))
end
|
129
130
131
132
|
# File 'app/presenters/search/activity_presenter.rb', line 129
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
|
#customer ⇒ Object
93
94
95
96
97
|
# File 'app/presenters/search/activity_presenter.rb', line 93
def customer
return unless r.has_columns?(:customer_id, :customer_full_name) && r.customer_id && r.customer_full_name
h.link_to(r.customer_full_name, h.customer_path(r.customer_id))
end
|
#customer_watch_symbol ⇒ Object
76
77
78
79
80
|
# File 'app/presenters/search/activity_presenter.rb', line 76
def customer_watch_symbol
return unless r.has_columns?(:customer_watch, :customer_open_sales_activity)
h.concat h.customer_watch_symbol_raw(r.customer_watch, r.customer_open_sales_activity)
end
|
#notes_indicator ⇒ Object
119
120
121
|
# File 'app/presenters/search/activity_presenter.rb', line 119
def notes_indicator
h.notes_popover compact_notes
end
|
#open_activity? ⇒ Boolean
12
13
14
|
# File 'app/presenters/search/activity_presenter.rb', line 12
def open_activity?
r.activity_type_task_type && r.activity_result_type_result_code.nil?
end
|
#original_target_datetime ⇒ Object
72
73
74
|
# File 'app/presenters/search/activity_presenter.rb', line 72
def original_target_datetime
h.render_date(r.original_target_datetime)
end
|
#records ⇒ Object
111
112
113
114
115
116
117
|
# File 'app/presenters/search/activity_presenter.rb', line 111
def records
h.content_tag(:ul, class: 'list-unstyled') do
[customer, contact, resource].compact.each do |link|
h.concat h.content_tag(:li, link)
end
end
end
|
#resource ⇒ Object
82
83
84
85
86
87
88
89
90
91
|
# File 'app/presenters/search/activity_presenter.rb', line 82
def resource
return unless r.has_columns?(:resource_id, :resource_type) && r.resource_type && r.resource_id
begin
res = r.resource
h.link_to(res.to_s, h.polymorphic_url(res))
rescue StandardError
res.to_s
end
end
|
#target_date ⇒ Object
52
53
54
|
# File 'app/presenters/search/activity_presenter.rb', line 52
def target_date
h.render_date(r.target_datetime)
end
|
#target_datetime ⇒ Object
48
49
50
|
# File 'app/presenters/search/activity_presenter.rb', line 48
def target_datetime
h.render_datetime(r.target_datetime)
end
|
#target_time ⇒ Object
56
57
58
|
# File 'app/presenters/search/activity_presenter.rb', line 56
def target_time
h.render_time(r.target_datetime)
end
|
#time_at_location ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/presenters/search/activity_presenter.rb', line 33
def time_at_location
return unless r.has_columns?(:time_at_location)
h.content_tag(:time, r.time_at_location, class: 'text-nowrap')
end
|