Sha256: 35475764a374227ce60550d8cbe8d7aaf2e9eb2133a37b4c0e0ed0257a5edca6

Contents?: true

Size: 997 Bytes

Versions: 2

Compression:

Stored size: 997 Bytes

Contents

module ActiveAdmin
  module Views
    class LocalizedAttributesTable < ActiveAdmin::Views::AttributesTable
      builder_method :localize_attributes_table_for

      def row(attr, &block)
        I18n.available_locales.each_with_index do |locale, index|
          @table << tr do
            if index == 0
              th :rowspan => I18n.available_locales.length do
                header_content_for(attr)
              end
            end
            td do
              I18n.with_locale locale do
                (
                  image_tag("aml/flags/#{locale.to_s}.png", alt: locale.to_s, title: locale.to_s) +
                  ' ' +
                  content_for(block || attr)
                ).html_safe
              end
            end
          end
        end
      end

      protected

      def default_id_for_prefix
        'attributes_table'
      end

      def default_class_name
        'attributes_table'
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activeadmin-mongoid-localize-0.3.1 lib/activeadmin-mongoid-localize/attributes_table.rb
activeadmin-mongoid-localize-0.2.2 lib/activeadmin-mongoid-localize/attributes_table.rb