Sha256: 49d749f3d09da5e1c3c422911e1a73aa20de3562975cd148257ccdc0cbe35c69

Contents?: true

Size: 1.55 KB

Versions: 726

Compression:

Stored size: 1.55 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::HashProp, 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

726 entries across 726 versions & 1 rubygems

Version Path
playbook_ui-14.11.1.pre.alpha.PLAY17445539 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.PBNTR798datepickerturbo5537 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.pbntr703collapsiblerowsrails5536 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.PLAY1751pbcontenttagpt25529 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.PBNTR7495495 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.12.0.pre.rc.11 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.12.0.pre.rc.10 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.12.0.pre.rc.9 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.12.0.pre.rc.8 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.12.0.pre.rc.7 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5437 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.PBNTR719listdraggablesimple5432 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.PBNTR768stickyrightcolumn5431 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.12.0.pre.rc.6 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5415 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5413 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.12.0.pre.rc.5 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5409 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5400 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5392 app/pb_kits/playbook/pb_source/source.rb