Module: Alchemy::Admin::AjaxFormsHelper

Defined in:
app/helpers/alchemy/admin/ajax_forms_helper.rb

Instance Method Summary collapse

Instance Method Details

#alchemy_body_classObject



5
6
7
8
9
10
11
12
13
# File 'app/helpers/alchemy/admin/ajax_forms_helper.rb', line 5

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

#search_panel(options = {}, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/alchemy/admin/ajax_forms_helper.rb', line 15

def search_panel(options = {}, &block)
  submit_button = options.fetch(:enable_submit, true)
  klass = options.delete(:class) || []
  (: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 << (: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 << (:div, class: "action_buttons") do
            f.submit(::I18n.t('alchemy_ajax_form.submit_search'))
          end
        end
        sb
      end
    end
  end
end