Class: SolidusAdmin::UI::Pages::Index::Component
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- SolidusAdmin::UI::Pages::Index::Component
show all
- Includes:
- Layout::PageHelpers
- Defined in:
- app/components/solidus_admin/ui/pages/index/component.rb
Direct Known Subclasses
OptionTypes::Index::Component, Orders::Index::Component, PaymentMethods::Index::Component, Products::Index::Component, PromotionCategories::Index::Component, Promotions::Index::Component, Properties::Index::Component, RefundsAndReturns::Component, Shipping::Component, StockItems::Index::Component, Stores::Index::Component, Taxes::Component, Taxonomies::Index::Component, SolidusAdmin::Users::Index::Component, Zones::Index::Component
Defined Under Namespace
Classes: Tab
Instance Method Summary
collapse
Constructor Details
#initialize(page:) ⇒ Component
Returns a new instance of Component.
12
13
14
15
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 12
def initialize(page:)
@page = page
@tabs = tabs&.map { |tab| Tab.new(**tab) }
end
|
Instance Method Details
#batch_actions ⇒ Object
57
58
59
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 57
def batch_actions
[]
end
|
#columns ⇒ Object
69
70
71
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 69
def columns
[]
end
|
#filters ⇒ Object
65
66
67
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 65
def filters
[]
end
|
#model_class ⇒ Object
21
22
23
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 21
def model_class
nil
end
|
#next_page_path ⇒ Object
77
78
79
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 77
def next_page_path
solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
end
|
#page_actions ⇒ Object
116
117
118
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 116
def page_actions
nil
end
|
#prev_page_path ⇒ Object
73
74
75
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 73
def prev_page_path
solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
end
|
#render_table ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 98
def render_table
render component('ui/table').new(
id: stimulus_id,
data: {
class: model_class,
rows: rows,
fade: -> { row_fade(_1) },
prev: prev_page_path,
next: next_page_path,
columns: columns,
batch_actions: batch_actions,
url: -> { row_url(_1) },
},
search: search_options,
sortable: sortable_options,
)
end
|
#row_fade(_record) ⇒ Object
17
18
19
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 17
def row_fade(_record)
false
end
|
#row_url(_record) ⇒ Object
53
54
55
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 53
def row_url(_record)
nil
end
|
#rows ⇒ Object
49
50
51
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 49
def rows
@page.records
end
|
#scopes ⇒ Object
61
62
63
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 61
def scopes
[]
end
|
#search_key ⇒ Object
29
30
31
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 29
def search_key
nil
end
|
#search_name ⇒ Object
37
38
39
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 37
def search_name
:q
end
|
#search_options ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 81
def search_options
return unless search_url
{
name: search_name,
value: search_params,
url: search_url,
searchbar_key: search_key,
filters: filters,
scopes: scopes,
}
end
|
#search_params ⇒ Object
33
34
35
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 33
def search_params
params[:q]
end
|
#search_url ⇒ Object
41
42
43
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 41
def search_url
nil
end
|
#sortable_options ⇒ Object
94
95
96
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 94
def sortable_options
nil
end
|
#table_id ⇒ Object
45
46
47
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 45
def table_id
stimulus_id
end
|
#tabs ⇒ Object
8
9
10
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 8
def tabs
nil
end
|
#title ⇒ Object
25
26
27
|
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 25
def title
model_class.model_name.human.pluralize
end
|