Class: Maglev::Uikit::List::ListComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/maglev/uikit/list/list_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseComponent

#button_class_names

Constructor Details

#initialize(sort_form: nil, sortable_scope: nil, html_options: {}) ⇒ ListComponent

Returns a new instance of ListComponent.



14
15
16
17
18
# File 'app/components/maglev/uikit/list/list_component.rb', line 14

def initialize(sort_form: nil, sortable_scope: nil, html_options: {})
  @sort_form = sort_form
  @sortable_scope = sortable_scope
  @html_options = html_options
end

Instance Attribute Details

#html_optionsObject (readonly)

Returns the value of attribute html_options.



12
13
14
# File 'app/components/maglev/uikit/list/list_component.rb', line 12

def html_options
  @html_options
end

#sort_formObject (readonly)

Returns the value of attribute sort_form.



12
13
14
# File 'app/components/maglev/uikit/list/list_component.rb', line 12

def sort_form
  @sort_form
end

#sortable_scopeObject (readonly)

Returns the value of attribute sortable_scope.



12
13
14
# File 'app/components/maglev/uikit/list/list_component.rb', line 12

def sortable_scope
  @sortable_scope
end

Instance Method Details

#sort_form_dataObject



24
25
26
# File 'app/components/maglev/uikit/list/list_component.rb', line 24

def sort_form_data
  { sortable_target: 'sortableForm' }.merge(sort_form[:data] || {})
end

#sort_form_pathObject



20
21
22
# File 'app/components/maglev/uikit/list/list_component.rb', line 20

def sort_form_path
  sort_form&.fetch(:path)
end

#sortable?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/components/maglev/uikit/list/list_component.rb', line 28

def sortable?
  sort_form_path.present?
end