Class: Maglev::Uikit::Form::ComboboxComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/maglev/uikit/form/combobox_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, name:, search_path:, options: {}, html_options: {}) ⇒ ComboboxComponent

options:

value: nil, placeholder: nil, error: nil, selected_label: nil,
clearable: false, spread_fields: false

html_options: { data: { attribute: ‘value’ } }



14
15
16
17
18
19
20
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 14

def initialize(label:, name:, search_path:, options: {}, html_options: {})
  @label = label
  @name = name
  @search_path = search_path
  @options = options
  @html_options = html_options
end

Instance Attribute Details

#html_optionsObject (readonly)

Returns the value of attribute html_options.



7
8
9
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 7

def html_options
  @html_options
end

#labelObject (readonly)

Returns the value of attribute label.



7
8
9
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 7

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 7

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 7

def options
  @options
end

#search_pathObject (readonly)

Returns the value of attribute search_path.



7
8
9
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 7

def search_path
  @search_path
end

Instance Method Details

#clearable?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 50

def clearable?
  options[:clearable]
end

#dom_idObject



22
23
24
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 22

def dom_id
  name.to_s.parameterize.underscore
end

#errorObject



46
47
48
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 46

def error
  options[:error]
end

#hintObject



34
35
36
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 34

def hint
  options[:hint]
end

#label_nameObject



42
43
44
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 42

def label_name
  options[:label_name]
end

#placeholderObject



38
39
40
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 38

def placeholder
  options[:placeholder]
end

#selected_labelObject



26
27
28
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 26

def selected_label
  options[:selected_label]
end

#spread_fields?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 54

def spread_fields?
  options[:spread_fields]
end

#turbo_frame_nameObject



58
59
60
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 58

def turbo_frame_name
  "#{dom_id}_combobox"
end

#valueObject



30
31
32
# File 'app/components/maglev/uikit/form/combobox_component.rb', line 30

def value
  options[:value]
end