Sha256: 202a25b029ab76630da7bcc65198a6837373fe8e51bfebdfcee1a5834409b572

Contents?: true

Size: 774 Bytes

Versions: 2

Compression:

Stored size: 774 Bytes

Contents

# frozen_string_literal: true

module Wallaby
  module Resources
    module Index
      # Html cell
      class HasManyHtml < Cell
        # @return [String]
        def render
          unique_collection = value.uniq
          concat raw unique_collection.first(2).map { |item| show_link item, options: { readonly: true } }.join(', ')
          if unique_collection.length > 2
            title = metadata[:label]
            body = unique_collection.map { |item| show_link item, options: { readonly: true } }.to_sentence.html_safe
            label = "#{unique_collection.length - 2} more"
            concat 'and'
            imodal title, body, label: label
          elsif unique_collection.blank?
            null
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wallaby-6.0.2 app/views/wallaby/resources/index/has_many_html.rb
wallaby-6.0.1 app/views/wallaby/resources/index/has_many_html.rb