Module: ExportsHelper

Defined in:
app/helpers/exports_helper.rb

Constant Summary collapse

BOOLEAN_OPTIONS =
[nil, ["true", 1], ["false", 0]].freeze
FORM_TAG_CLASS =
"form-control"

Instance Method Summary collapse

Instance Method Details

#filter_value_field(rexport_model, field) ⇒ Object



7
8
9
10
11
12
# File 'app/helpers/exports_helper.rb', line 7

def filter_value_field(rexport_model, field)
  ActiveSupport::Deprecation.warn(
    "Calling #filter_value_field is deprecated. Use #rexport_filter_form_tag instead"
  )
  rexport_filter_tag(@export, rexport_model, field) # rubocop:disable Rails/HelperInstanceVariable
end

#rexport_filter_tag(export, rexport_model, field) ⇒ Object

rubocop:disable Metrics/MethodLength



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/helpers/exports_helper.rb', line 14

def rexport_filter_tag(export, rexport_model, field) # rubocop:disable Metrics/MethodLength
  filter_field = rexport_model.field_path(rexport_model.filter_column(field))
  tag_name = "export[export_filter_attributes][#{filter_field}]"
  value = export.filter_value(filter_field)

  case field.type
  when :association
    association, text_method = field.method.split(".")
    association_filter_select_tag(
      tag_name,
      association_filter_options(
        rexport_model.collection_from_association(association),
        text_method,
        value
      )
    )
  when :boolean
    boolean_filter_select_tag(tag_name, value)
  when :date, :integer, :string
    text_field_tag(tag_name, value, class: FORM_TAG_CLASS)
  end
end