Sha256: 6756a6ea3e198ac6c94dbe50f01627a2f75fb27f2016d0dbd55a1a77f8bb3b3e

Contents?: true

Size: 715 Bytes

Versions: 20

Compression:

Stored size: 715 Bytes

Contents

# frozen_string_literal: true

module Effective
  module TableRows
    class Collection < Effective::TableRow

      def initialize(name, collection, options, builder:)
        @collection = collection
        super(name, options, builder: builder)
      end

      def content
        values = Array(value) - [nil, '']

        if values.length > 1
          values.map { |v| content_tag(:div, item_content(v)) }.join.html_safe
        elsif values.length == 1
          item_content(values.first)
        end
      end

      def item_content(value)
        item = @collection.find { |k, v| (k && k == value) || (v && v == value) || k.try(:id) == value }
        (item || value).to_s
      end

    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
effective_bootstrap-1.18.1 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.18.0 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.17.6 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.17.5 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.17.4 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.17.3 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.17.2 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.17.1 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.17.0 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.16.4 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.16.3 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.16.2 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.16.1 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.16.0 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.15.6 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.15.5 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.15.4 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.15.3 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.15.2 app/models/effective/table_rows/collection.rb
effective_bootstrap-1.15.1 app/models/effective/table_rows/collection.rb