Class: SolidusAdmin::OptionTypes::Index::Component

Inherits:
UI::Pages::Index::Component
  • Object
show all
Defined in:
app/components/solidus_admin/option_types/index/component.rb

Instance Method Summary collapse

Instance Method Details

#batch_actionsObject



36
37
38
39
40
41
42
43
44
45
# File 'app/components/solidus_admin/option_types/index/component.rb', line 36

def batch_actions
  [
    {
      label: t('.batch_actions.delete'),
      action: solidus_admin.option_types_path,
      method: :delete,
      icon: 'delete-bin-7-line',
    },
  ]
end

#columnsObject



47
48
49
50
51
52
# File 'app/components/solidus_admin/option_types/index/component.rb', line 47

def columns
  [
    name_column,
    presentation_column,
  ]
end

#model_classObject



4
5
6
# File 'app/components/solidus_admin/option_types/index/component.rb', line 4

def model_class
  Spree::OptionType
end

#name_columnObject



54
55
56
57
58
59
60
61
# File 'app/components/solidus_admin/option_types/index/component.rb', line 54

def name_column
  {
    header: :name,
    data: ->(option_type) do
       :div, option_type.name
    end
  }
end

#next_page_pathObject



32
33
34
# File 'app/components/solidus_admin/option_types/index/component.rb', line 32

def next_page_path
  solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
end

#page_actionsObject



19
20
21
22
23
24
25
26
# File 'app/components/solidus_admin/option_types/index/component.rb', line 19

def page_actions
  render component("ui/button").new(
    tag: :a,
    text: t('.add'),
    href: spree.new_admin_option_type_path,
    icon: "add-line",
  )
end

#presentation_columnObject



63
64
65
66
67
68
69
70
# File 'app/components/solidus_admin/option_types/index/component.rb', line 63

def presentation_column
  {
    header: :presentation,
    data: ->(option_type) do
       :div, option_type.presentation
    end
  }
end

#prev_page_pathObject



28
29
30
# File 'app/components/solidus_admin/option_types/index/component.rb', line 28

def prev_page_path
  solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
end

#row_url(option_type) ⇒ Object



8
9
10
# File 'app/components/solidus_admin/option_types/index/component.rb', line 8

def row_url(option_type)
  spree.edit_admin_option_type_path(option_type)
end

#sortable_optionsObject



12
13
14
15
16
17
# File 'app/components/solidus_admin/option_types/index/component.rb', line 12

def sortable_options
  {
    url: ->(option_type) { solidus_admin.move_option_type_path(option_type) },
    param: 'position',
  }
end