Module: QuickSearchHelper

Defined in:
app/helpers/quick_search_helper.rb

Overview

View helper: quick search.

Instance Method Summary collapse

Instance Method Details

#quick_search_icon_for(result_class, size: '2x', family: 'fas', **options) ⇒ ActiveSupport::SafeBuffer

Icon for a quick search result class, for the navbar type picker.

Shares Crm::QuickSearchResultCardComponent's map rather than keeping a
second one: the copy that lived here had drifted, and purchase_order,
voucher and credit_memo were falling through to the question mark.

Parameters:

  • result_class (String, Symbol)

    result type, e.g. :order or 'support_case'

  • size (String) (defaults to: '2x')

    Font Awesome size suffix, emitted as fa-

  • family (String) (defaults to: 'fas')

    Font Awesome family, passed through to fa_icon

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :class (String)

    extra CSS classes merged onto the icon

Returns:

  • (ActiveSupport::SafeBuffer)


16
17
18
19
20
21
# File 'app/helpers/quick_search_helper.rb', line 16

def quick_search_icon_for(result_class, size: '2x', family: 'fas', **options)
  icon_name = Crm::QuickSearchResultCardComponent::RESULT_CLASS_ICONS
              .fetch(result_class.to_s.to_sym, 'question-square')

  fa_icon(icon_name, family: family, class: [options[:class], "fa-#{size}"].compact.join(' '))
end