Class: Search::ActivityPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::ActivityPresenter
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/activity_presenter.rb
Overview
Row presenter for ViewActivity — renders the cells in the CRM activity
search/results table.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#activity_link ⇒ ActiveSupport::SafeBuffer
Linked activity task type → activity show page, styled by open/closed state.
-
#assigned_resource ⇒ ActiveSupport::SafeBuffer?
Assigned-resource block, highlighting the current user and showing the original assignee when reassigned.
-
#assigned_to_current_user? ⇒ Boolean
Whether this activity is assigned to the currently logged-in user.
-
#campaign ⇒ ActiveSupport::SafeBuffer?
Linked campaign name → campaign show page.
-
#compact_notes ⇒ String?
Sanitized activity notes/description with bracketed text removed.
-
#completion_date ⇒ String
Completion date rendered through the shared
render_datehelper. -
#completion_datetime ⇒ String
Completion datetime rendered through the shared
render_datetimehelper. -
#completion_time ⇒ String
Completion time rendered through the shared
render_timehelper. -
#contact ⇒ ActiveSupport::SafeBuffer?
Linked contact name → contact show page.
-
#contact_button ⇒ ActiveSupport::SafeBuffer
Dropdown of callable contact points for the activity's customer.
-
#customer ⇒ ActiveSupport::SafeBuffer?
Linked customer name → customer show page.
-
#customer_watch_symbol ⇒ ActiveSupport::SafeBuffer?
Customer watch / open-sales-activity indicator symbol.
-
#notes_indicator ⇒ ActiveSupport::SafeBuffer
Notes popover for the activity.
-
#open_activity? ⇒ Boolean
Whether the activity is still open (has a task type but no result code).
-
#original_target_datetime ⇒ String
Original target datetime rendered through the shared
render_datehelper. -
#records ⇒ ActiveSupport::SafeBuffer
Unordered list of customer, contact, and resource links.
-
#resource ⇒ ActiveSupport::SafeBuffer, ...
Linked polymorphic resource (opportunity, order, etc.) → its show page.
-
#target_date ⇒ String
Target date rendered through the shared
render_datehelper. -
#target_datetime ⇒ String
Target datetime rendered through the shared
render_datetimehelper. -
#target_time ⇒ String
Target time rendered through the shared
render_timehelper. -
#time_at_location ⇒ ActiveSupport::SafeBuffer?
Time-at-location value wrapped in a non-breaking
<time>tag.
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
#activity_link ⇒ ActiveSupport::SafeBuffer
Linked activity task type → activity show page, styled by open/closed state.
38 39 40 41 42 43 44 45 46 |
# File 'app/presenters/search/activity_presenter.rb', line 38 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 ⇒ ActiveSupport::SafeBuffer?
Assigned-resource block, highlighting the current user and showing
the original assignee when reassigned.
28 29 30 31 32 33 |
# File 'app/presenters/search/activity_presenter.rb', line 28 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-body-secondary' 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
Whether this activity is assigned to the currently logged-in user.
13 14 15 |
# File 'app/presenters/search/activity_presenter.rb', line 13 def assigned_to_current_user? h.current_user.id == r.assigned_resource_id end |
#campaign ⇒ ActiveSupport::SafeBuffer?
Linked campaign name → campaign show page.
159 160 161 162 163 |
# File 'app/presenters/search/activity_presenter.rb', line 159 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 ⇒ String?
Sanitized activity notes/description with bracketed text removed.
186 187 188 189 190 |
# File 'app/presenters/search/activity_presenter.rb', line 186 def compact_notes cn = r.try(:notes) || r.try(:description) cn = cn.gsub(/\[.*\]/, '').strip if cn cn end |
#completion_date ⇒ String
Completion date rendered through the shared render_date helper.
97 98 99 |
# File 'app/presenters/search/activity_presenter.rb', line 97 def completion_date h.render_date(r.completion_datetime) end |
#completion_datetime ⇒ String
Completion datetime rendered through the shared render_datetime helper.
90 91 92 |
# File 'app/presenters/search/activity_presenter.rb', line 90 def completion_datetime h.render_datetime(r.completion_datetime) end |
#completion_time ⇒ String
Completion time rendered through the shared render_time helper.
104 105 106 |
# File 'app/presenters/search/activity_presenter.rb', line 104 def completion_time h.render_time(r.completion_datetime) end |
#contact ⇒ ActiveSupport::SafeBuffer?
Linked contact name → contact show page.
150 151 152 153 154 |
# File 'app/presenters/search/activity_presenter.rb', line 150 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 |
#contact_button ⇒ ActiveSupport::SafeBuffer
Dropdown of callable contact points for the activity's customer.
195 196 197 198 |
# File 'app/presenters/search/activity_presenter.rb', line 195 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 |
#customer ⇒ ActiveSupport::SafeBuffer?
Linked customer name → customer show page.
141 142 143 144 145 |
# File 'app/presenters/search/activity_presenter.rb', line 141 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 ⇒ ActiveSupport::SafeBuffer?
Customer watch / open-sales-activity indicator symbol.
118 119 120 121 122 |
# File 'app/presenters/search/activity_presenter.rb', line 118 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 ⇒ ActiveSupport::SafeBuffer
Notes popover for the activity.
179 180 181 |
# File 'app/presenters/search/activity_presenter.rb', line 179 def notes_indicator h.notes_popover compact_notes end |
#open_activity? ⇒ Boolean
Whether the activity is still open (has a task type but no result code).
20 21 22 |
# File 'app/presenters/search/activity_presenter.rb', line 20 def open_activity? r.activity_type_task_type && r.activity_result_type_result_code.nil? end |
#original_target_datetime ⇒ String
Original target datetime rendered through the shared render_date helper.
111 112 113 |
# File 'app/presenters/search/activity_presenter.rb', line 111 def original_target_datetime h.render_date(r.original_target_datetime) end |
#records ⇒ ActiveSupport::SafeBuffer
Unordered list of customer, contact, and resource links.
168 169 170 171 172 173 174 |
# File 'app/presenters/search/activity_presenter.rb', line 168 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 ⇒ ActiveSupport::SafeBuffer, ...
Linked polymorphic resource (opportunity, order, etc.) → its show page.
127 128 129 130 131 132 133 134 135 136 |
# File 'app/presenters/search/activity_presenter.rb', line 127 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 ⇒ String
Target date rendered through the shared render_date helper.
76 77 78 |
# File 'app/presenters/search/activity_presenter.rb', line 76 def target_date h.render_date(r.target_datetime) end |
#target_datetime ⇒ String
Target datetime rendered through the shared render_datetime helper.
69 70 71 |
# File 'app/presenters/search/activity_presenter.rb', line 69 def target_datetime h.render_datetime(r.target_datetime) end |
#target_time ⇒ String
Target time rendered through the shared render_time helper.
83 84 85 |
# File 'app/presenters/search/activity_presenter.rb', line 83 def target_time h.render_time(r.target_datetime) end |
#time_at_location ⇒ ActiveSupport::SafeBuffer?
Time-at-location value wrapped in a non-breaking <time> tag.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/presenters/search/activity_presenter.rb', line 51 def time_at_location return unless r.has_columns?(:time_at_location) h.content_tag(:time, r.time_at_location, class: 'text-nowrap') # this time at location was set incorrectly in the view, for e.g.: # irb(main):082:0> ViewActivity.last.time_at_location # Sat, 01 Jan 2000 04:19:25.806658000 CST -06:00 # So, let's assume the time part is correct at UTC and render it in the viewer's time zone # t = nil # Time.use_zone('UTC') do # t=Time.zone.parse(r.time_at_location.to_s) # end # h.render_time(t) end |