Class: Crm::ActivityCardComponent

Inherits:
ApplicationComponent show all
Includes:
ActionView::Helpers::FormTagHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper, ActionView::RecordIdentifier
Defined in:
app/components/crm/activity_card_component.rb

Delegated Instance Attributes collapse

Methods inherited from ApplicationComponent

#cms_link, #image_asset_tag, #image_tag, #number_to_currency, #number_with_delimiter, #post_path, #post_url, #strip_tags

Instance Method Summary collapse

Methods inherited from ApplicationComponent

#fetch_or_fallback

Constructor Details

#initialize(activity:, selected_activity_id: nil, context_object: nil) ⇒ ActivityCardComponent

Returns a new instance of ActivityCardComponent.



13
14
15
16
17
18
# File 'app/components/crm/activity_card_component.rb', line 13

def initialize(activity:, selected_activity_id: nil, context_object: nil)
  super()
  @activity = activity
  @context_object = context_object
  @pre_open = activity.persisted? && selected_activity_id == activity.id
end

Instance Method Details

#notes_previewObject

Strips HTML and normalises whitespace for the collapsed summary row.
Visual truncation is handled by CSS line-clamp; the full text is kept
in the DOM so the "Activities" toggle can reveal it without a fetch.
Returns nil when there is no previewable text.



28
29
30
31
32
33
34
# File 'app/components/crm/activity_card_component.rb', line 28

def notes_preview
  text = activity.notes.presence || activity.description.presence
  return unless text

  strip_tags(text.gsub(/<\/(p|div|br|li|h\d)>/i, " "))
    .gsub(/\s+/, " ").strip.presence
end

#pre_open?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/components/crm/activity_card_component.rb', line 20

def pre_open?
  @pre_open
end

#render_activity_formObject

Alias for Helpers#render_activity_form

Returns:

  • (Object)

    Helpers#render_activity_form

See Also:



11
# File 'app/components/crm/activity_card_component.rb', line 11

delegate :truncate, :render_date, :render_activity_form, to: :helpers

#render_dateObject

Alias for Helpers#render_date

Returns:

  • (Object)

    Helpers#render_date

See Also:



11
# File 'app/components/crm/activity_card_component.rb', line 11

delegate :truncate, :render_date, :render_activity_form, to: :helpers

#truncateObject

Alias for Helpers#truncate

Returns:

  • (Object)

    Helpers#truncate

See Also:



11
# File 'app/components/crm/activity_card_component.rb', line 11

delegate :truncate, :render_date, :render_activity_form, to: :helpers