Sha256: 351e0145acacc9ae9138610480d55f3fa4835026e1aeb09a5cf49ea95804d863

Contents?: true

Size: 1.04 KB

Versions: 17

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true
require "active_admin/component"

module ActiveAdmin
  module BatchActions

    # Build a BatchActionForm
    class BatchActionForm < ActiveAdmin::Component
      builder_method :batch_action_form

      attr_reader :prefix_html

      def build(options = {}, &block)
        options[:id] ||= "collection_selection"

        # Open a form with two hidden input fields:
        # batch_action        => name of the specific action called
        # batch_action_inputs => a JSON string of any requested confirmation values
        text_node form_tag active_admin_config.route_batch_action_path(params, url_options), id: options[:id]
        input name: :batch_action, id: :batch_action, type: :hidden
        input name: :batch_action_inputs, id: :batch_action_inputs, type: :hidden

        super(options)
      end

      # Override the default to_s to include a closing form tag
      def to_s
        content + closing_form_tag
      end

      private

      def closing_form_tag
        "</form>".html_safe
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
activeadmin-3.2.5 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-3.2.4 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-3.2.3 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-3.2.2 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-3.2.1 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-3.2.0 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-3.1.0 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-3.0.0 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-2.14.0 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-2.13.1 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-2.13.0 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-2.12.0 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-2.11.2 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-2.11.1 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-2.11.0 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-2.10.1 lib/active_admin/batch_actions/views/batch_action_form.rb
activeadmin-2.10.0 lib/active_admin/batch_actions/views/batch_action_form.rb