Class: Playbook::PbSource::Source

Inherits:
KitBase
  • Object
show all
Defined in:
app/pb_kits/playbook/pb_source/source.rb

Instance Method Summary collapse

Methods inherited from KitBase

#object

Methods included from NumberSpacing

included

Methods included from ZIndex

included

Methods included from Spacing

included, #max_width_options, #max_width_props, #max_width_values, #spacing_options, #spacing_props, #spacing_values

Methods included from Classnames

#generate_classname, #generate_classname_without_spacing, included

Methods included from Playbook::Props

#initialize, #prop

Methods included from Playbook::PbKitHelper

#pb_rails

Methods included from Playbook::PbFormsHelper

#pb_form_with

Instance Method Details

#avatarObject



26
27
28
29
30
31
32
33
# File 'app/pb_kits/playbook/pb_source/source.rb', line 26

def avatar
  if user.present? && (type == "user" || type == "referral")
    avatar_props = user.clone
    avatar_props[:size] = "sm"
    avatar_props.delete(:user_id)
    avatar_props
  end
end

#classnameObject



56
57
58
# File 'app/pb_kits/playbook/pb_source/source.rb', line 56

def classname
  generate_classname("pb_source_kit")
end

#show_icon?Boolean

Returns:



22
23
24
# File 'app/pb_kits/playbook/pb_source/source.rb', line 22

def show_icon?
  !type_icon_name.nil? && avatar.nil?
end

#type_icon_nameObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/pb_kits/playbook/pb_source/source.rb', line 39

def type_icon_name
  case type
  when "retail"
    "shopping-bag"
  when "inbound"
    "sign-in"
  when "outbound"
    "sign-out"
  when "prospecting"
    "binoculars"
  when "events"
    "calendar-alt"
  when "referral"
    "handshake"
  end
end

#type_textObject



14
15
16
17
18
19
20
# File 'app/pb_kits/playbook/pb_source/source.rb', line 14

def type_text
  if type == "user" || (type == "referral" && user.present?)
    user[:name]
  else
    type.titleize
  end
end

#user_idObject



35
36
37
# File 'app/pb_kits/playbook/pb_source/source.rb', line 35

def user_id
  user.dig(:user_id)
end