Class: Decidim::FilterFormBuilder

Inherits:
FormBuilder
  • Object
show all
Defined in:
lib/decidim/filter_form_builder.rb

Overview

This custom FormBuilder is used to create resource filter forms

Instance Method Summary collapse

Methods inherited from FormBuilder

#attachment, #check_box, #choose_button_label, #create_language_selector, #data_picker, #date_field, #datetime_field, #editor, #form_field_for, #hashtaggable_text_field, #label_for, #max_file_size, #password_field, #resources_select, #social_field, #text_area, #translated, #translated_one_locale, #upload, #upload_help

Methods included from Map::Autocomplete::FormBuilder

#geocoding_field

Methods included from TranslatableAttributes

#default_locale?

Instance Method Details

#areas_select(method, collection, options = {}, html_options = {}) ⇒ Object

Wrap the areas select in a custom fieldset.



58
59
60
61
62
# File 'lib/decidim/filter_form_builder.rb', line 58

def areas_select(method, collection, options = {}, html_options = {})
  fieldset_wrapper(options[:legend_title], "#{method}_areas_select_filter") do
    super(method, collection, options, html_options)
  end
end

#categories_select(method, collection, options = {}, html_options = {}) ⇒ Object

Wrap the category select in a custom fieldset.



51
52
53
54
55
# File 'lib/decidim/filter_form_builder.rb', line 51

def categories_select(method, collection, options = {}, html_options = {})
  fieldset_wrapper(options.delete(:legend_title), "#{method}_categories_select_filter") do
    super(method, collection, options, html_options)
  end
end

#check_boxes_tree(method, collection, options = {}) ⇒ Object

Wrap the dependant check_boxes in a custom fieldset. checked parent checks its children



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/decidim/filter_form_builder.rb', line 38

def check_boxes_tree(method, collection, options = {})
  fieldset_wrapper(options.delete(:legend_title), "#{method}_check_boxes_tree_filter") do
    @template.render("decidim/shared/check_boxes_tree",
                     form: self,
                     attribute: method,
                     collection: collection,
                     check_boxes_tree_id: check_boxes_tree_id(method),
                     hide_node: "false",
                     options: options).html_safe
  end
end

#collection_check_boxes(method, collection, value_method, label_method, options = {}, html_options = {}) ⇒ Object

Wrap the check_boxes collection in a custom fieldset. It also renders the inputs inside its labels.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/decidim/filter_form_builder.rb', line 24

def collection_check_boxes(method, collection, value_method, label_method, options = {}, html_options = {})
  fieldset_wrapper(options[:legend_title], "#{method}_collection_check_boxes_filter") do
    super(method, collection, value_method, label_method, options, html_options) do |builder|
      if block_given?
        yield builder
      else
        builder.label { builder.check_box + builder.text }
      end
    end
  end
end

#collection_radio_buttons(method, collection, value_method, label_method, options = {}, html_options = {}) ⇒ Object

Wrap the radio buttons collection in a custom fieldset. It also renders the inputs inside its labels.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/decidim/filter_form_builder.rb', line 10

def collection_radio_buttons(method, collection, value_method, label_method, options = {}, html_options = {})
  fieldset_wrapper(options[:legend_title], "#{method}_collection_radio_buttons_filter") do
    super(method, collection, value_method, label_method, options, html_options) do |builder|
      if block_given?
        yield builder
      else
        builder.label { builder.radio_button + builder.text }
      end
    end
  end
end

#custom_select(name, method, collection, options = {}) ⇒ Object

Wrap the custom select in a custom fieldset. Any *_select can be used as a custom_select; what changes is the superclass method, and this one knows which one has to be called, depending on the ‘name` provided.



67
68
69
70
71
# File 'lib/decidim/filter_form_builder.rb', line 67

def custom_select(name, method, collection, options = {})
  fieldset_wrapper(options[:legend_title], "#{method}_#{name}_select_filter") do
    send(:"#{name}_select", method, collection, options)
  end
end

#scopes_picker(method, options = { checkboxes_on_top: true }) ⇒ Object

Wrap the scopes picker in a custom fieldset.



74
75
76
77
78
# File 'lib/decidim/filter_form_builder.rb', line 74

def scopes_picker(method, options = { checkboxes_on_top: true })
  fieldset_wrapper(options[:legend_title], "#{method}_scopes_picker_filter") do
    super(method, options)
  end
end