Class: Crm::ActivityCardComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Crm::ActivityCardComponent
- 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
-
#render_activity_form ⇒ Object
Alias for Helpers#render_activity_form.
-
#render_date ⇒ Object
Alias for Helpers#render_date.
-
#truncate ⇒ Object
Alias for Helpers#truncate.
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
-
#initialize(activity:, selected_activity_id: nil, context_object: nil) ⇒ ActivityCardComponent
constructor
A new instance of ActivityCardComponent.
-
#notes_preview ⇒ Object
Strips HTML and normalises whitespace for the collapsed summary row.
- #pre_open? ⇒ Boolean
Methods inherited from ApplicationComponent
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_preview ⇒ Object
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 (text.gsub(/<\/(p|div|br|li|h\d)>/i, " ")) .gsub(/\s+/, " ").strip.presence end |
#pre_open? ⇒ Boolean
20 21 22 |
# File 'app/components/crm/activity_card_component.rb', line 20 def pre_open? @pre_open end |
#render_activity_form ⇒ Object
Alias for Helpers#render_activity_form
11 |
# File 'app/components/crm/activity_card_component.rb', line 11 delegate :truncate, :render_date, :render_activity_form, to: :helpers |
#render_date ⇒ Object
Alias for Helpers#render_date
11 |
# File 'app/components/crm/activity_card_component.rb', line 11 delegate :truncate, :render_date, :render_activity_form, to: :helpers |
#truncate ⇒ Object
Alias for Helpers#truncate
11 |
# File 'app/components/crm/activity_card_component.rb', line 11 delegate :truncate, :render_date, :render_activity_form, to: :helpers |