Class: HotwireCombobox::Component

Inherits:
Object
  • Object
show all
Includes:
Announced, Associations, Async, Customizable, Freetext, Multiselect, Paginated, Markup::Dialog, Markup::Fieldset, Markup::Form, Markup::Handle, Markup::HiddenField, Markup::Input, Markup::Label, Markup::Listbox, Markup::Wrapper
Defined in:
app/presenters/hotwire_combobox/component.rb

Defined Under Namespace

Modules: Announced, Associations, Async, Customizable, Freetext, Multiselect, Paginated

Constant Summary

Constants included from Customizable

Customizable::CUSTOMIZABLE_ELEMENTS, Customizable::PROTECTED_ATTRS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Announced

#announcer_attrs

Methods included from Paginated

#paginated?, #pagination_attrs

Constructor Details

#initialize(view, name, association_name: nil, async_src: nil, autocomplete: :both, data: {}, dialog_label: nil, form: nil, free_text: false, id: nil, input: {}, label: nil, mobile_at: "640px", multiselect_chip_src: nil, name_when_new: nil, open: false, options: [], preload: false, request: nil, value: nil, **rest) ⇒ Component

Returns a new instance of Component.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/presenters/hotwire_combobox/component.rb', line 12

def initialize(
  view, name,
  association_name: nil,
  async_src: nil,
  autocomplete: :both,
  data: {},
  dialog_label: nil,
  form: nil,
  free_text: false,
  id: nil,
  input: {},
  label: nil,
  mobile_at: "640px",
  multiselect_chip_src: nil,
  name_when_new: nil,
  open: false,
  options: [],
  preload: false,
  request: nil,
  value: nil, **rest)
  @view, @autocomplete, @id, @name, @value, @form, @async_src, @label, @free_text, @request,
  @preload, @name_when_new, @open, @data, @mobile_at, @multiselect_chip_src, @options, @dialog_label =
    view, autocomplete, id, name.to_s, value, form, async_src, label, free_text, request,
    preload, name_when_new, open, data, mobile_at, multiselect_chip_src, options, dialog_label

  @combobox_attrs = input.reverse_merge(rest).deep_symbolize_keys
  @association_name = association_name || infer_association_name

  validate!
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



10
11
12
# File 'app/presenters/hotwire_combobox/component.rb', line 10

def label
  @label
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'app/presenters/hotwire_combobox/component.rb', line 10

def options
  @options
end

Instance Method Details

#render_in(view_context, &block) ⇒ Object



43
44
45
46
# File 'app/presenters/hotwire_combobox/component.rb', line 43

def render_in(view_context, &block)
  block.call(self) if block_given?
  view_context.render partial: "hotwire_combobox/component", locals: { component: self }, formats: [ :html ]
end