Class: Playbook::PbSource::Source

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

Instance Method Summary collapse

Methods included from Playbook::Props

#generate_classname, #initialize, #prop

Instance Method Details

#avatarObject



30
31
32
33
34
35
36
37
# File 'app/pb_kits/playbook/pb_source/source.rb', line 30

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



60
61
62
# File 'app/pb_kits/playbook/pb_source/source.rb', line 60

def classname
  generate_classname("pb_source_kit")
end

#show_icon?Boolean

Returns:



26
27
28
# File 'app/pb_kits/playbook/pb_source/source.rb', line 26

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

#type_icon_nameObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/pb_kits/playbook/pb_source/source.rb', line 43

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



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

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

#user_idObject



39
40
41
# File 'app/pb_kits/playbook/pb_source/source.rb', line 39

def user_id
  user.dig(:user_id)
end