Class: Anchor::FilterComponent
- Defined in:
- app/components/anchor/filter_component.rb
Constant Summary collapse
- TYPE_DEFAULT =
:select
- TYPE_OPTIONS =
[TYPE_DEFAULT, :checkbox, :radio].freeze
- FROM_REQUEST =
:_request
Constants included from ViewHelper
Instance Method Summary collapse
-
#initialize(label:, options:, param_key:, selected: FROM_REQUEST, type: TYPE_DEFAULT, default_selected: false, **kwargs) ⇒ FilterComponent
constructor
A new instance of FilterComponent.
Methods inherited from Component
Methods included from ViewHelper
#anchor_form_with, #anchor_svg, #deep_blank?, #merge_options, #popover_trigger_attributes
Methods included from FetchOrFallbackHelper
Constructor Details
#initialize(label:, options:, param_key:, selected: FROM_REQUEST, type: TYPE_DEFAULT, default_selected: false, **kwargs) ⇒ FilterComponent
Returns a new instance of FilterComponent.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/components/anchor/filter_component.rb', line 7 def initialize( label:, options:, param_key:, selected: FROM_REQUEST, type: TYPE_DEFAULT, default_selected: false, **kwargs ) @label = label @blank_option = .detect { |_text, value| value.nil? } @every_option = @options = - [blank_option] @param_key = param_key @selected = selected @type = fetch_or_fallback(TYPE_OPTIONS, type, TYPE_DEFAULT) @default_selected = default_selected super(**kwargs) end |