Sha256: 79c6a98a9026899318bb124410e78799c2aa126ce5f9718b82a3334d30c02e29

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Capybara
  module ActiveAdmin
    module Selectors
      # Selectors for *table_for*, it's rows and cells.
      module Table
        # @param resource_name [String, nil] active admin resource name.
        # @return selector.
        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

        # @param record_id [String, Integer, nil] record ID.
        # @return selector.
        def table_row_selector(record_id = nil)
          return 'tbody > tr' if record_id.nil?

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

        # @return selector.
        def table_header_selector
          'thead > tr > th.col'
        end

        # @param column [String, nil] column name.
        # @return selector.
        def table_cell_selector(column = nil)
          return 'td.col' if column.nil?

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capybara_active_admin-0.3.3 lib/capybara/active_admin/selectors/table.rb
capybara_active_admin-0.3.2 lib/capybara/active_admin/selectors/table.rb