Class: FlexiAdmin::Components::Resource::AutocompleteComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- FlexiAdmin::Components::Resource::AutocompleteComponent
- Includes:
- Helpers::ResourceHelper
- Defined in:
- lib/flexi_admin/components/resource/autocomplete_component.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #autocomplete_options ⇒ Object
-
#initialize(resource = nil, scope:, fields: [:title], action: :select, parent: nil, path: nil, value: nil, **html_options) ⇒ AutocompleteComponent
constructor
A new instance of AutocompleteComponent.
Methods included from Helpers::ResourceHelper
#autocomplete_path, #bulk_action_path, #datalist_path, #edit_resource_path, #paginate, #resource__path, #resource_input_name, #resource_path, #resources_path, #scope, #scope_plural, #scope_singular
Constructor Details
#initialize(resource = nil, scope:, fields: [:title], action: :select, parent: nil, path: nil, value: nil, **html_options) ⇒ AutocompleteComponent
Returns a new instance of AutocompleteComponent.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 11 def initialize(resource = nil, scope:, fields: [:title], action: :select, parent: nil, path: nil, value: nil, **) @resource = resource @scope = scope @parent = parent @fields = fields @path = path @action = action @value = value @html_options = @width = .delete(:width) @required = [:required] @style = .delete(:style) @disabled = .key?(:disabled) ? [:disabled] : false @name = [:name] || resource_input_name validate_action! end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
8 9 10 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 8 def action @action end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
8 9 10 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 8 def disabled @disabled end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
8 9 10 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 8 def fields @fields end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
8 9 10 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 8 def @html_options end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 8 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
8 9 10 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 8 def parent @parent end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 8 def path @path end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
8 9 10 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 8 def required @required end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
8 9 10 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 8 def resource @resource end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 8 def value @value end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
8 9 10 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 8 def width @width end |
Instance Method Details
#autocomplete_options ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/flexi_admin/components/resource/autocomplete_component.rb', line 32 def { style: 'border-top-right-radius: 0.4rem; border-bottom-right-radius: 0.4rem;', data: { autocomplete_target: 'input', action: 'keyup->autocomplete#keyup focusout->autocomplete#onFocusOut', autocomplete_search_path: get_path, autocomplete_is_disabled: disabled, field_type: kind }.merge() } end |