Sha256: 46c2e8e8efbef3d8125a0f0ed88884ffc97b1db51c4bda3b4c0d5191b6eda4a5

Contents?: true

Size: 1.47 KB

Versions: 204

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbSource
    class Source
      include Playbook::Props

      partial "pb_source/source"

      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

Version data entries

204 entries across 204 versions & 1 rubygems

Version Path
playbook_ui-7.14.0.pre.alpha1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.16.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.15.1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.15.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.14.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.13.0.pre.alpha1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.13.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.12.1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.12.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.11.1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.11.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.11.0.pre.alpha1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.10.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.9.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.8.4 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.8.3 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.8.2 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.8.1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.8.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-7.7.0.pre.alpha1 app/pb_kits/playbook/pb_source/source.rb