Class: Search::ActivityTextPresenter

Inherits:
ActivityPresenter
  • Object
show all
Defined in:
app/presenters/search/activity_text_presenter.rb

Overview

Plain-text variant of ActivityPresenter for CSV/Excel exports.

Instance Method Summary collapse

Instance Method Details

Activity task type label (no link).

Returns:

  • (String)


15
16
17
# File 'app/presenters/search/activity_text_presenter.rb', line 15

def activity_link
  r.activity_type_task_type
end

#assigned_resourceString?

Assigned resource full name (no HTML wrapper).

Returns:

  • (String, nil)


8
9
10
# File 'app/presenters/search/activity_text_presenter.rb', line 8

def assigned_resource
  r.assigned_resource_full_name
end

#campaignString?

Campaign name (no link).

Returns:

  • (String, nil)


62
63
64
65
66
# File 'app/presenters/search/activity_text_presenter.rb', line 62

def campaign
  return unless r.has_columns?(:campaign_id, :campaign_name) && r.campaign_id && r.campaign_name

  r.campaign_name.to_s
end

#compact_notesString?

Sanitized activity notes/description with bracketed text removed.

Returns:

  • (String, nil)


78
79
80
81
82
# File 'app/presenters/search/activity_text_presenter.rb', line 78

def compact_notes
  cn = r.try(:notes) || r.try(:description)
  cn = cn.gsub(/\[.*\]/, '').strip if cn
  cn
end

#contactString?

Contact name with id (no link).

Returns:

  • (String, nil)


53
54
55
56
57
# File 'app/presenters/search/activity_text_presenter.rb', line 53

def contact
  return unless r.has_columns?(:contact_id, :contact_full_name) && r.contact_id && r.contact_full_name

  "#{r.contact_full_name} (#{r.contact_id})"
end

#customerString?

Customer name with account number (no link).

Returns:

  • (String, nil)


44
45
46
47
48
# File 'app/presenters/search/activity_text_presenter.rb', line 44

def customer
  return unless r.has_columns?(:customer_id, :customer_full_name) && r.customer_id && r.customer_full_name

  "#{r.customer.full_name} (CN#{r.customer_id})"
end

#customer_watch_symbolString

Textual customer-watch / open-sales-activity indicator.

Returns:

  • (String)


22
23
24
25
26
27
# File 'app/presenters/search/activity_text_presenter.rb', line 22

def customer_watch_symbol
  res = []
  res << 'Watched' if r.customer_watch
  res << 'Open Sales Activity' if r.customer_open_sales_activity
  res.join('-')
end

#notes_indicatorString

Plain-text notes indicator.

Returns:

  • (String)


71
72
73
# File 'app/presenters/search/activity_text_presenter.rb', line 71

def notes_indicator
  h.text_only(compact_notes)
end

#resourceString?

Polymorphic resource record, rendered as its to_s value.

Returns:

  • (String, nil)


32
33
34
35
36
37
38
39
# File 'app/presenters/search/activity_text_presenter.rb', line 32

def resource
  return unless r.has_columns?(:resource_id, :resource_type) && r.resource_type && r.resource_id

  res = r.resource_type.constantize.find(r.resource_id)
  return unless res

  res.to_s
end