Sha256: fd05c906f6f0180a8138e34c2d6d8c956aec9c9ebfe590d8b5f76621f6a425c5

Contents?: true

Size: 1.12 KB

Versions: 68

Compression:

Stored size: 1.12 KB

Contents

module Pageflow
  module ActiveAdminPatches
    module Views
      module TableFor
        def row_attributes
          @collection.each_with_index do |item, i|
            tr = @tbody.children[i]

            attributes = yield(item)
            attributes[:class] = [tr.attributes[:class], attributes[:class]].compact.join(' ')

            tr.attributes.merge!(attributes)
          end
        end

        def boolean_status_tag_column(name, yes_state = :warning)
          status_tag_column(name,
                            [I18n.t('active_admin.status_tag.yes'), '-'],
                            [yes_state, nil])
        end

        private

        def status_tag_column(name, texts, types)
          column name do |resource|
            value = resource.send(name)

            status = value ? 'yes' : 'no'
            text = value ? texts.first : texts.last
            type = value ? types.first : types.last

            if type
              status_tag(status, class: [type, name.to_s.gsub(/\?$/, '')].join(' '), label: text)
            else
              text
            end
          end
        end
      end
    end
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
pageflow-17.0.4 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-17.0.3 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-17.0.2 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-17.0.1 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-17.0.0 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-16.2.0 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-16.1.0 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-16.0.0 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-15.8.0 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-14.5.2 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-15.7.1 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-15.7.0 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-15.6.1 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-15.6.0 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-15.5.0 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-15.4.0 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-15.3.0 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-15.2.2 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-15.2.1 lib/pageflow/active_admin_patches/views/table_for.rb
pageflow-15.2.0 lib/pageflow/active_admin_patches/views/table_for.rb