Class: SourceMonitor::FilterDropdownComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/source_monitor/filter_dropdown_component.rb

Overview

Renders a labeled filter dropdown with auto-submit behavior. Used across sources, items, and logs index views to provide consistent filter select styling and behavior.

Constant Summary collapse

SELECT_CLASSES =
"rounded-md border border-slate-200 bg-white px-2 py-2 text-sm " \
"text-slate-700 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
LABEL_CLASSES =
"block text-xs font-medium text-slate-500 mb-1"

Instance Method Summary collapse

Constructor Details

#initialize(label:, param_name:, options:, selected_value: nil, form: nil) ⇒ FilterDropdownComponent

Returns a new instance of FilterDropdownComponent.

Parameters:

  • label (String)

    visible label text for the dropdown

  • param_name (Symbol, String)

    the form parameter name

  • options (Array<Array>)

    array of [label, value] pairs for the select

  • selected_value (String, nil) (defaults to: nil)

    currently selected value

  • form (ActionView::Helpers::FormBuilder, nil) (defaults to: nil)

    optional form builder for Ransack integration



17
18
19
20
21
22
23
# File 'app/components/source_monitor/filter_dropdown_component.rb', line 17

def initialize(label:, param_name:, options:, selected_value: nil, form: nil)
  @label = label
  @param_name = param_name
  @options = options
  @selected_value = selected_value.to_s
  @form = form
end

Instance Method Details

#callObject



25
26
27
28
29
# File 'app/components/source_monitor/filter_dropdown_component.rb', line 25

def call
  (:div) do
    safe_join([ render_label, render_select ])
  end
end