Class: ActiveAdmin::Views::TableFor

Inherits:
Object
  • Object
show all
Defined in:
lib/active_admin/patches/views/table_for.rb

Instance Method Summary collapse

Instance Method Details

#boolean_status_tag_column(name, yes_state = :warning) ⇒ Object


29
30
31
# File 'lib/active_admin/patches/views/table_for.rb', line 29

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

#row_attributes(&block) ⇒ Object


4
5
6
7
8
9
10
11
12
13
# File 'lib/active_admin/patches/views/table_for.rb', line 4

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

#status_tag_column(name, texts, states) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_admin/patches/views/table_for.rb', line 15

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