Module: Crm::ContactTrainingTopicsHelper

Defined in:
app/helpers/crm/contact_training_topics_helper.rb

Overview

View helpers for the contact training topics UI: renders a badge icon
reflecting a contact's training state on a topic.

Instance Method Summary collapse

Instance Method Details

#contact_training_topic_badge(state) ⇒ ActiveSupport::SafeBuffer?

Renders a Font Awesome badge icon for a contact's training state
(reviewed → green thumbs-up, certified → gold certificate).

Examples:

contact_training_topic_badge(:certified) # => gold certificate icon

Parameters:

  • state (String, Symbol, nil)

    the training state; anything other
    than reviewed or certified (including nil) renders nothing

Returns:

  • (ActiveSupport::SafeBuffer, nil)

    the icon markup, or nil when
    the state is blank or has no badge



15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/crm/contact_training_topics_helper.rb', line 15

def contact_training_topic_badge(state)
  return unless state

  icon_map = {
               reviewed: { icon: 'thumbs-o-up', style: 'color: green' },
               certified: { icon: 'certificate', style: 'color: gold' }
             }
  return unless (badge_data = icon_map[state.to_sym])

  fa_icon(badge_data[:icon], style: badge_data[:style])
end