Class: Katalyst::Tables::Query::SuggestionComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
HtmlAttributes
Defined in:
app/components/katalyst/tables/query/suggestion_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(suggestion:, index:) ⇒ SuggestionComponent

Returns a new instance of SuggestionComponent.



11
12
13
14
15
16
# File 'app/components/katalyst/tables/query/suggestion_component.rb', line 11

def initialize(suggestion:, index:, **)
  super(**)

  @suggestion = suggestion
  @index      = index
end

Instance Method Details

#default_html_attributesObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/components/katalyst/tables/query/suggestion_component.rb', line 22

def default_html_attributes
  {
    id:    dom_id,
    class: ["suggestion", type.to_s],
    role:  "option",
    data:  {
      action:                    %w[
        click->tables--query#selectSuggestion
        query:select->tables--query#selectSuggestion
      ],
      tables__query_value_param: value_param,
    },
  }
end

#dom_idObject



18
19
20
# File 'app/components/katalyst/tables/query/suggestion_component.rb', line 18

def dom_id
  "suggestion_#{@index}"
end