Sha256: 7e4c15faa90a74feaa00698f2ab2c4e463c23a8acd0cac7c1b82428aec67a9ea

Contents?: true

Size: 960 Bytes

Versions: 1

Compression:

Stored size: 960 Bytes

Contents

# frozen_string_literal: true

module Capybara
  module ActiveAdmin
    module Selectors
      module Table
        def table_selector(resource_name)
          return 'table.index_table' if resource_name.nil?

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

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

          model_name = model_name.model_name.singular if model_name.is_a?(Class)
          model_name = model_name.to_s.gsub(' ', '_').singularize.downcase
          "tbody > tr##{model_name}_#{record_id}"
        end

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

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