Module: Capybara::ActiveAdmin::Selectors::Table

Included in:
Capybara::ActiveAdmin::Selectors
Defined in:
lib/capybara/active_admin/selectors/table.rb

Overview

Selectors for table_for, it’s rows and cells.

Instance Method Summary collapse

Instance Method Details

#table_cell_selector(column = nil) ⇒ Object

Returns selector.

Parameters:

  • column (String, nil) (defaults to: nil)

    column name.

Returns:

  • selector.



32
33
34
35
36
37
# File 'lib/capybara/active_admin/selectors/table.rb', line 32

def table_cell_selector(column = nil)
  return 'td.col' if column.nil?

  column = column.to_s.gsub(' ', '_').downcase
  "td.col.col-#{column}"
end

#table_header_selectorObject

Returns selector.

Returns:

  • selector.



26
27
28
# File 'lib/capybara/active_admin/selectors/table.rb', line 26

def table_header_selector
  'thead > tr > th.col'
end

#table_row_selector(record_id = nil) ⇒ Object

Returns selector.

Parameters:

  • record_id (String, Integer, nil) (defaults to: nil)

    record ID.

Returns:

  • selector.



19
20
21
22
23
# File 'lib/capybara/active_admin/selectors/table.rb', line 19

def table_row_selector(record_id = nil)
  return 'tbody > tr' if record_id.nil?

  %(tbody > tr[id$="_#{record_id}"])
end

#table_selector(resource_name = nil) ⇒ Object

Returns selector.

Parameters:

  • resource_name (String, nil) (defaults to: nil)

    active admin resource name.

Returns:

  • selector.



10
11
12
13
14
15
# File 'lib/capybara/active_admin/selectors/table.rb', line 10

def table_selector(resource_name = nil)
  return 'table.index_table' if resource_name.nil?

  resource_name = resource_name.to_s.gsub(' ', '_').pluralize.downcase
  "table#index_table_#{resource_name}"
end