Sha256: 237ba1cf7c9570ff6738c2d1351b25d96b4a22f5a6b4dc3f44f9a09300c9c458

Contents?: true

Size: 1.54 KB

Versions: 345

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

# rubocop:disable Style/SingleArgumentDig, Style/HashLikeCase
module Playbook
  module PbSource
    class Source < Playbook::KitBase
      prop :hide_icon, type: Playbook::Props::Boolean,
                       default: false
      prop :source, type: Playbook::Props::String
      prop :type, type: Playbook::Props::Enum,
                  values: %w[user retail inbound outbound prospecting events referral],
                  default: "inbound"
      prop :user, type: Playbook::Props::Hash, default: {}

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

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

      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

      def user_id
        user.dig(:user_id)
      end

      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

      def classname
        generate_classname("pb_source_kit")
      end
    end
  end
end

# rubocop:enable Style/SingleArgumentDig, Style/HashLikeCase

Version data entries

345 entries across 345 versions & 1 rubygems

Version Path
playbook_ui-12.38.0.pre.alpha.PLAY966collapsiblenav41086 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.38.0.pre.alpha.audiencesalpha1083 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.38.0.pre.alpha.PLAY966collapsiblenav41082 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.38.0.pre.alpha.PLAYaddingdatapropselectkit1080 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.37.0.pre.alpha.PLAY951collapsiblenav31078 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.38.0.pre.alpha.playbook123801077 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.37.0.pre.alpha.PLAY951collapsiblenav31074 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.37.0.pre.alpha.PLAY951collapsiblenav31073 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.37.0.pre.alpha.PLAYaddingdatapropselectkit1071 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.38.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.37.0.pre.alpha.svgiconmethods1064 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.37.0.pre.alpha.PLAY951collapsiblenav31062 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.37.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.36.0.pre.alpha.svgiconmethods1059 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.36.0.pre.alpha.PLAY936momentjs1058 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.36.0.pre.alpha.PLAY936momentjs1050 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.36.0.pre.alpha.PLAY936momentjs1047 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.36.0.pre.alpha.svgiconmethods1043 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.36.0.pre.alpha.PLAY942collapsiblenav21035 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-12.36.0 app/pb_kits/playbook/pb_source/source.rb