Class: Impulse::Autocomplete::GroupComponent

Inherits:
Impulse::ApplicationComponent show all
Defined in:
app/components/impulse/autocomplete/group_component.rb

Instance Method Summary collapse

Methods inherited from Impulse::ApplicationComponent

generate_id

Methods included from Helpers::AttributesHelper

#merge_attributes

Constructor Details

#initialize(title:, **system_args) ⇒ GroupComponent

Returns a new instance of GroupComponent.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/components/impulse/autocomplete/group_component.rb', line 6

def initialize(title:, **system_args)
  @id = self.class.generate_id
  @title = title
  @system_args = system_args
  @system_args[:tag] = :div
  @system_args[:role] = :group
  @system_args["aria-labelledby"] = @id
  @system_args[:class] = class_names(system_args[:class], "awc-autocomplete-group")

  @system_args[:"data-text"] = title
  @system_args[:data] = merge_attributes(
    system_args[:data],
    target: "awc-autocomplete.groups"
  )
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/components/impulse/autocomplete/group_component.rb', line 22

def render?
  options.present?
end