Class: SolidusAdmin::PaymentMethods::Index::Component

Inherits:
UI::Pages::Index::Component
  • Object
show all
Defined in:
app/components/solidus_admin/payment_methods/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/payment_methods/index/component.rb', line 36

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

#columnsObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/components/solidus_admin/payment_methods/index/component.rb', line 57

def columns
  [
    {
      header: :name,
      data: ->(payment_method) do
         :div, payment_method.name
      end
    },
    {
      header: :type,
      data: ->(payment_method) do
         :div, payment_method.model_name.human
      end
    },
    {
      header: :available_to_users,
      data: ->(payment_method) do
        if payment_method.available_to_users?
          component('ui/badge').yes
        else
          component('ui/badge').no
        end
      end
    },
    {
      header: :available_to_admin,
      data: ->(payment_method) do
        if payment_method.available_to_admin?
          component('ui/badge').yes
        else
          component('ui/badge').no
        end
      end
    },
    {
      header: :status,
      data: ->(payment_method) do
        if payment_method.active?
          render component('ui/badge').new(name: t('.status.active'), color: :green)
        else
          render component('ui/badge').new(name: t('.status.inactive'), color: :graphite_light)
        end
      end
    },
  ]
end

#model_classObject



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

def model_class
  Spree::PaymentMethod
end

#page_actionsObject



27
28
29
30
31
32
33
34
# File 'app/components/solidus_admin/payment_methods/index/component.rb', line 27

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

#row_url(payment_method) ⇒ Object



16
17
18
# File 'app/components/solidus_admin/payment_methods/index/component.rb', line 16

def row_url(payment_method)
  spree.edit_admin_payment_method_path(payment_method)
end

#scopesObject



47
48
49
50
51
52
53
54
55
# File 'app/components/solidus_admin/payment_methods/index/component.rb', line 47

def scopes
  [
    { name: :all, label: t('.scopes.all'), default: true },
    { name: :active, label: t('.scopes.active') },
    { name: :inactive, label: t('.scopes.inactive') },
    { name: :storefront, label: t('.scopes.storefront') },
    { name: :admin, label: t('.scopes.admin') },
  ]
end

#search_keyObject



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

def search_key
  :name_or_description_cont
end

#search_urlObject



12
13
14
# File 'app/components/solidus_admin/payment_methods/index/component.rb', line 12

def search_url
  solidus_admin.payment_methods_path
end

#sortable_optionsObject



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

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