Module: Capybara::ActiveAdmin::Selectors::Table
- Defined in:
- lib/capybara/active_admin/selectors/table.rb
Overview
Selectors for table_for, it's rows and cells.
Instance Method Summary collapse
-
#table_cell_selector(column = nil) ⇒ Object
Selector.
-
#table_header_selector(text = nil, options = {}) ⇒ Object
Selector.
-
#table_row_selector(record_id = nil) ⇒ Object
Selector.
- #table_scope_selector ⇒ Object
- #table_scopes_container_selector ⇒ Object
-
#table_selector(resource_name = nil) ⇒ Object
Selector.
Instance Method Details
#table_cell_selector(column = nil) ⇒ Object
Returns selector.
43 44 45 46 47 48 49 |
# File 'lib/capybara/active_admin/selectors/table.rb', line 43 def table_cell_selector(column = nil) return 'td.col' if column.nil? # Downcase, strip non-alphanumeric chars (e.g. '/'), convert spaces to '_', deduplicate '_' column = column.to_s.downcase.gsub(/[^a-z0-9\s]/, '').gsub(/\s+/, '_').squeeze('_') "td.col.col-#{column}" end |
#table_header_selector(text = nil, options = {}) ⇒ Object
Returns selector.
31 32 33 34 35 36 37 38 39 |
# File 'lib/capybara/active_admin/selectors/table.rb', line 31 def table_header_selector(text = nil, = {}) return 'thead > tr > th.col' if text.nil? column = ([:column] || text).to_s.tr(' ', '_').downcase selector = "th.col.col-#{column}" selector += '.sortable' if [:sortable] selector += ".sorted-#{[:sort_direction].to_s.downcase}" if [:sort_direction].present? "thead > tr > #{selector}" end |
#table_row_selector(record_id = nil) ⇒ Object
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_scope_selector ⇒ Object
55 56 57 |
# File 'lib/capybara/active_admin/selectors/table.rb', line 55 def table_scope_selector 'li.scope' end |
#table_scopes_container_selector ⇒ Object
51 52 53 |
# File 'lib/capybara/active_admin/selectors/table.rb', line 51 def table_scopes_container_selector '.scopes > ul.table_tools_segmented_control' end |
#table_selector(resource_name = nil) ⇒ Object
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 |