Class: Crm::QuickSearchResultCardComponent

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

Overview

Renders a quick search result card with profile image support.
Works with QuickSearch::*Presenter classes - accepts presenter data via as_json.

Examples:

From presenter hash

<% presenter.as_json.each do |data| %>
  <%= render Crm::QuickSearchResultCardComponent.new(**data) %>
<% end %>

Direct initialization

<%= render Crm::QuickSearchResultCardComponent.new(
  title: "John Doe",
  sub_header: "Chicago, IL",
  url: customer_path(customer),
  result_class: :customer,
  ref: "CN12345",
  profile_image_url: "https://..."
) %>

Constant Summary collapse

RESULT_CLASS_ICONS =
{
  contact: 'address-card',
  customer: 'user-friends',
  supplier: 'warehouse',
  publication: 'book',
  opportunity: 'business-time',
  item: 'box-full',
  catalog_item: 'box-full',
  room_configuration: 'ruler-triangle',
  quote: 'ruler-combined',
  shipment: 'pallet',
  order: 'box-usd',
  invoice: 'file-invoice-dollar',
  support_case: 'user-headset',
  rma: 'hand-holding-box',
  history: 'clock-rotate-left',
  credit_memo: 'file-invoice-dollar',
  delivery: 'truck',
  voucher: 'ticket',
  purchase_order: 'clipboard-list',
  activity: 'calendar-check',
  address: 'map-marker-alt',
  email_preference: 'envelope-open-text',
  contact_point: 'phone'
}.freeze

Instance Method Summary collapse

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(title:, url:, result_class:, sub_header: nil, text_sub_header: nil, type_label: nil, ref: nil, profile_image_url: nil) ⇒ QuickSearchResultCardComponent

Initialize with presenter data (from as_json) or direct attributes

Parameters:

  • title (String)

    Display title (with reference number)

  • sub_header (String) (defaults to: nil)

    Badge HTML for header row, or plain text for body

  • text_sub_header (String) (defaults to: nil)

    Explicit text subtitle for body area

  • url (String)

    Link destination

  • result_class (Symbol)

    Type of result (for icon/styling)

  • type_label (String) (defaults to: nil)

    Optional custom label for the type badge

  • ref (String) (defaults to: nil)

    Reference number to display in card body

  • profile_image_url (String) (defaults to: nil)

    Optional profile image URL



61
62
63
64
65
66
67
68
69
70
71
# File 'app/components/crm/quick_search_result_card_component.rb', line 61

def initialize(title:, url:, result_class:, sub_header: nil, text_sub_header: nil, type_label: nil, ref: nil, profile_image_url: nil)
  super()
  @title = title
  @sub_header = sub_header
  @text_sub_header = text_sub_header
  @url = url
  @result_class = result_class&.to_sym
  @type_label_override = type_label
  @ref = ref
  @profile_image_url = profile_image_url
end