-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
component.rb
61 lines (54 loc) 路 1.29 KB
/
component.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# frozen_string_literal: true
class SolidusAdmin::ShippingMethods::Index::Component < SolidusAdmin::Shipping::Component
def model_class
Spree::ShippingMethod
end
def row_url(shipping_method)
spree.edit_admin_shipping_method_path(shipping_method)
end
def search_url
solidus_admin.shipping_methods_path
end
def search_key
:name_or_description_cont
end
def page_actions
render component("ui/button").new(
tag: :a,
text: t('.add'),
href: spree.new_admin_shipping_method_path,
icon: "add-line",
class: "align-self-end w-full",
)
end
def batch_actions
[
{
label: t('.batch_actions.delete'),
action: solidus_admin.shipping_methods_path,
method: :delete,
icon: 'delete-bin-7-line',
},
]
end
def columns
[
{
header: :name,
data: -> { [_1.admin_name.presence, _1.name].compact.join(' / ') },
},
{
header: :zone,
data: -> { _1.zones.pluck(:name).to_sentence },
},
{
header: :calculator,
data: -> { _1.calculator&.description },
},
{
header: :available_to_users,
data: -> { _1.available_to_users? ? component('ui/badge').yes : component('ui/badge').no },
},
]
end
end