Sha256: 89a60e383848c9896c6aeee46335ddd7a18f7cea8c2bd7142939a66d162eef2a

Contents?: true

Size: 808 Bytes

Versions: 22

Compression:

Stored size: 808 Bytes

Contents

class ActiveAdmin::Views::TableFor
  alias_method :original_status_tag, :status_tag

  def row_attributes(&block)
    @collection.each_with_index do |item, i|
      tr = @tbody.children[i]

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

      tr.attributes.merge!(attributes)
    end
  end

  def status_tag_column(name, texts, states)
    column name do |resource|
      value = resource.send(name)
      text = value ? texts.first : texts.last
      state = value ? states.first : states.last

      if state
        original_status_tag text, state
      else
        text
      end
    end
  end

  def boolean_status_tag_column(name, yes_state = :warning)
    status_tag_column(name, ['Ja', '-'], [yes_state, nil])
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
pageflow-0.10.0 lib/active_admin/patches/views/table_for.rb
pageflow-0.9.2 lib/active_admin/patches/views/table_for.rb
pageflow-0.9.1 lib/active_admin/patches/views/table_for.rb
pageflow-0.9.0 lib/active_admin/patches/views/table_for.rb
pageflow-0.8.2 lib/active_admin/patches/views/table_for.rb
pageflow-0.8.1 lib/active_admin/patches/views/table_for.rb
pageflow-0.8.0 lib/active_admin/patches/views/table_for.rb
pageflow-0.7.2 lib/active_admin/patches/views/table_for.rb
pageflow-0.7.1 lib/active_admin/patches/views/table_for.rb
pageflow-0.7.0 lib/active_admin/patches/views/table_for.rb
pageflow-0.6.0 lib/active_admin/patches/views/table_for.rb
pageflow-0.5.0 lib/active_admin/patches/views/table_for.rb
pageflow-0.4.0 lib/active_admin/patches/views/table_for.rb
pageflow-0.3.0 lib/active_admin/patches/views/table_for.rb
pageflow-0.2.1 lib/active_admin/patches/views/table_for.rb
pageflow-0.2.0 lib/active_admin/patches/views/table_for.rb
pageflow-0.1.0 lib/active_admin/patches/views/table_for.rb
pageflow-0.0.5 lib/active_admin/patches/views/table_for.rb
pageflow-0.0.4 lib/active_admin/patches/views/table_for.rb
pageflow-0.0.3 lib/active_admin/patches/views/table_for.rb