Sha256: d811ddb16f51eb34675091fd82f285c9da682e9e60abdfd66b0436adf33b8b3b

Contents?: true

Size: 893 Bytes

Versions: 3

Compression:

Stored size: 893 Bytes

Contents

# frozen_string_literal: true

module Koi
  module SummaryList
    class ItemComponent < Base
      def render?
        !(@skip_blank && raw_value.blank? && raw_value != false)
      end

      def attribute_value
        # preserve the legacy syntax where the value is passed to the block
        if content?
          return @__vc_original_view_context.capture do
            @__vc_render_in_block.call(raw_value)
          end
        end

        case raw_value
        when Array
          raw_value.join(", ")
        when ActiveStorage::Attached::One
          raw_value.attached? ? link_to(raw_value.filename, url_for(raw_value)) : ""
        when Date, Time, DateTime, ActiveSupport::TimeWithZone
          l(raw_value, format: :admin)
        when TrueClass, FalseClass
          raw_value ? "Yes" : "No"
        else
          raw_value.to_s
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
katalyst-koi-4.5.0.beta.1 app/components/koi/summary_list/item_component.rb
katalyst-koi-4.4.1 app/components/koi/summary_list/item_component.rb
katalyst-koi-4.4.0 app/components/koi/summary_list/item_component.rb