Sha256: 8bc56c79eeaa480cd29d9f187b776a77f84b39f3588175305bde952217b423f9

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Capybara
  module ActiveAdmin
    module Finders
      module Form
        # @param name [Class<Object>, String] form record class or model name
        # @yield within form
        def within_form_for(name)
          name = name.model_name.singular if name.is_a?(Class)
          selector = form_selector(name)
          within(selector) { yield }
        end

        # @param association_name [String]
        # @param index [String] index of fieldset, starts with 0.
        # @yield within fieldset>ol
        def within_form_has_many(association_name, index: 0)
          selector = has_many_fields_selector(association_name)
          fieldset = find_all(selector, minimum: index + 1)[index]

          within(fieldset) { yield }
        end

        def find_input(label, options = {})
          label_opts = Util.options_with_text label, options.slice(:exact)
          label_node = find(label_selector, label_opts)

          input_id = label_node[:for]
          opts = options.except(:exact)
          find("##{input_id}", opts)
        end

        def within_filters
          selector = filter_form_selector
          within(selector) { yield }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capybara_active_admin-0.3.0 lib/capybara/active_admin/finders/form.rb