Sha256: 3ae891be535605fd07fa61998783a070a7849a419224781ca3594414a2eaca8d

Contents?: true

Size: 1.42 KB

Versions: 123

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

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

Version data entries

123 entries across 123 versions & 1 rubygems

Version Path
playbook_ui-9.3.0.pre.alpha.password.strength.1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-9.3.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-9.2.2.pre.alpha.margin app/pb_kits/playbook/pb_source/source.rb
playbook_ui-9.2.2 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-9.2.1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-9.2.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-9.1.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-9.0.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.3.0.alpha.select.pre.margin app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.3.0 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.2.1.pre.alpha5 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.2.1.pre.alpha4 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.2.1.alpha.iconacc app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.2.1.pre.alpha3 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.2.1.pre.alpha2 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.3.0.deps2 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.3.0.pre.alpha1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.2.1.pre.alpha1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.2.1 app/pb_kits/playbook/pb_source/source.rb
playbook_ui-8.1.3 app/pb_kits/playbook/pb_source/source.rb