Class: Search::ActivityPresenter
- Inherits:
-
BasePresenter
show all
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/activity_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
#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 = ['btn','btn-block']
if open_activity?
css_classes << 'btn-success'
else
css_classes << '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
14
15
16
17
18
19
20
21
|
# File 'app/presenters/search/activity_presenter.rb', line 14
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?)
if r.original_assigned_resource_id && r.assigned_resource_id && original_assigned_resource_id != r.assigned_resource_id
h.concat h.content_tag :del, r.original_assigned_resource_full_name, class: 'text-muted'
end
end
end
|
#assigned_to_current_user? ⇒ Boolean
6
7
8
|
# File 'app/presenters/search/activity_presenter.rb', line 6
def assigned_to_current_user?
h.current_user.id == r.assigned_resource_id
end
|
#campaign ⇒ Object
100
101
102
103
|
# File 'app/presenters/search/activity_presenter.rb', line 100
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
117
118
119
120
121
|
# File 'app/presenters/search/activity_presenter.rb', line 117
def compact_notes
cn = r.try(:notes) || r.try(:description)
cn = cn.gsub(/\[.*\]/,'').strip if cn
cn
end
|
#completion_date ⇒ Object
63
64
65
|
# File 'app/presenters/search/activity_presenter.rb', line 63
def completion_date
h.render_date(r.completion_datetime)
end
|
#completion_datetime ⇒ Object
59
60
61
|
# File 'app/presenters/search/activity_presenter.rb', line 59
def completion_datetime
h.render_datetime(r.completion_datetime)
end
|
#completion_time ⇒ Object
67
68
69
|
# File 'app/presenters/search/activity_presenter.rb', line 67
def completion_time
h.render_time(r.completion_datetime)
end
|
95
96
97
98
|
# File 'app/presenters/search/activity_presenter.rb', line 95
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
|
123
124
125
126
|
# File 'app/presenters/search/activity_presenter.rb', line 123
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
90
91
92
93
|
# File 'app/presenters/search/activity_presenter.rb', line 90
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
75
76
77
78
|
# File 'app/presenters/search/activity_presenter.rb', line 75
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
113
114
115
|
# File 'app/presenters/search/activity_presenter.rb', line 113
def notes_indicator
h.notes_popover compact_notes
end
|
#open_activity? ⇒ Boolean
10
11
12
|
# File 'app/presenters/search/activity_presenter.rb', line 10
def open_activity?
r.activity_type_task_type && r.activity_result_type_result_code.nil?
end
|
#original_target_datetime ⇒ Object
71
72
73
|
# File 'app/presenters/search/activity_presenter.rb', line 71
def original_target_datetime
h.render_date(r.original_target_datetime)
end
|
#records ⇒ Object
105
106
107
108
109
110
111
|
# File 'app/presenters/search/activity_presenter.rb', line 105
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
80
81
82
83
84
85
86
87
88
|
# File 'app/presenters/search/activity_presenter.rb', line 80
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 => exc
res.to_s
end
end
|
#target_date ⇒ Object
51
52
53
|
# File 'app/presenters/search/activity_presenter.rb', line 51
def target_date
h.render_date(r.target_datetime)
end
|
#target_datetime ⇒ Object
47
48
49
|
# File 'app/presenters/search/activity_presenter.rb', line 47
def target_datetime
h.render_datetime(r.target_datetime)
end
|
#target_time ⇒ Object
55
56
57
|
# File 'app/presenters/search/activity_presenter.rb', line 55
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
|
# 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
|