Class: Crm::ContactCardComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Crm::ContactCardComponent
- Includes:
- ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper
- Defined in:
- app/components/crm/contact_card_component.rb
Overview
Displays a contact or customer card with profile image, contact info, and contact points.
Used in customer contacts tab and other places where contact cards are displayed.
Instance Method Summary collapse
-
#before_render ⇒ Object
Called before rendering - set up values that depend on helpers.
-
#enqueue_profile_image_lookup ⇒ Object
Queue profile image lookup for parties without images (lazy backfill).
-
#initialize(contact:, return_path: nil, contact_points: nil, communication_options: {}, role: nil, note: nil, agreement_participant: nil) ⇒ ContactCardComponent
constructor
A new instance of ContactCardComponent.
Methods inherited from ApplicationComponent
#cms_link, #fetch_or_fallback, #image_asset_tag, #image_tag, #number_to_currency, #number_with_delimiter, #post_path, #post_url, #strip_tags
Constructor Details
#initialize(contact:, return_path: nil, contact_points: nil, communication_options: {}, role: nil, note: nil, agreement_participant: nil) ⇒ ContactCardComponent
Returns a new instance of ContactCardComponent.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/components/crm/contact_card_component.rb', line 23 def initialize( contact:, return_path: nil, contact_points: nil, communication_options: {}, role: nil, note: nil, agreement_participant: nil ) super() @contact = contact @return_path_override = return_path @contact_points = contact_points || contact.contact_points @communication_options = @role = role.presence || (contact.respond_to?(:job_title) ? contact.job_title : nil) @note = note @agreement_participant = agreement_participant # Trigger lazy profile image lookup if needed enqueue_profile_image_lookup end |
Instance Method Details
#before_render ⇒ Object
Called before rendering - set up values that depend on helpers
46 47 48 |
# File 'app/components/crm/contact_card_component.rb', line 46 def before_render @return_path = @return_path_override || helpers.polymorphic_path(contact, tab: 'contacts') end |
#enqueue_profile_image_lookup ⇒ Object
Queue profile image lookup for parties without images (lazy backfill)
51 52 53 54 55 56 |
# File 'app/components/crm/contact_card_component.rb', line 51 def enqueue_profile_image_lookup return if contact.profile_image_id.present? return if contact.inactive? PartyProfileImageWorker.perform_async(contact.id) end |