Sha256: d513ab5c58445c6d66d72a13d28425bd76257715ab38442b1dacbc93d2052e8a

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

module Alchemy
  module Admin
    module AjaxFormsHelper

      def alchemy_body_class
        [
            "ajax_forms",
            controller_name,
            action_name,
            content_for(:main_menu_style),
            content_for(:alchemy_body_class)
        ].compact
      end

      def search_panel(options = {}, &block)
        submit_button = options.fetch(:enable_submit, true)
        klass = options.delete(:class) || []
        content_tag(:div, class: "search_panel #{klass.join(" ")}", ** options) do
          if @query
            simple_form_for(@query, url: polymorphic_path([:admin, @query.klass]), method: :get) do |f|
              sb = ActiveSupport::SafeBuffer.new

              sb << content_tag(:div, class: "search_fields_group") do
                search_fields = ActiveSupport::SafeBuffer.new
                search_fields << f.input(resource_handler.search_field_name,
                                         label: false,
                                         input_html: {
                                             class: 'search_input_field',
                                             placeholder: Alchemy.t(:search)
                                         },
                                         wrapper_html: {
                                             class: "full-width"
                                         }

                )

                search_fields << capture do
                  block.call(f)
                end
                search_fields
              end
              if submit_button
                sb << content_tag(:div, class: "action_buttons") do
                  f.submit(::I18n.t('alchemy_ajax_form.submit_search'))
                end
              end
              sb
            end
          end
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alchemy-ajax-form-1.2.1 app/helpers/alchemy/admin/ajax_forms_helper.rb
alchemy-ajax-form-2.1.0 app/helpers/alchemy/admin/ajax_forms_helper.rb
alchemy-ajax-form-2.0.0 app/helpers/alchemy/admin/ajax_forms_helper.rb
alchemy-ajax-form-1.2.0 app/helpers/alchemy/admin/ajax_forms_helper.rb