Skip to content

Commit a2c2b3c

Browse files
committed
Align previews with recent changes in ui/table and ui/pagination components
1 parent 3b77454 commit a2c2b3c

File tree

3 files changed

+14
-27
lines changed

3 files changed

+14
-27
lines changed

admin/spec/components/previews/solidus_admin/ui/table/component_preview.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ def simple
1717
model_class.new(id: n, name: "Product #{n}", price: n * 10.0, available_on: n.days.ago)
1818
end
1919

20-
page = Struct.new(:records, :number, :next_param, :first?, :last?).new(rows, 1, '#', true, false)
21-
22-
page.records.define_singleton_method(:model) do
20+
rows.define_singleton_method(:model) do
2321
model_class
2422
end
2523

2624
render component("ui/table").new(
27-
page: page,
28-
path: ->(_page_number) { "#" },
25+
rows: rows,
26+
search_key: :name_cont,
27+
search_page_url: '',
28+
turbo_frame_id: 'products',
29+
previous_page_url: nil,
30+
next_page_url: nil,
2931
columns: [
3032
{ header: :id, data: -> { _1.id.to_s } },
3133
{ header: :name, data: :name },

admin/spec/components/previews/solidus_admin/ui/table/pagination/component_preview.rb

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,16 @@ class SolidusAdmin::UI::Table::Pagination::ComponentPreview < ViewComponent::Pre
55
include SolidusAdmin::Preview
66

77
def overview
8-
render_with_template(
9-
locals: {
10-
page: page_proc,
11-
path: path_proc
12-
}
13-
)
8+
render_with_template
149
end
1510

1611
# @param left toggle
1712
# @param right toggle
1813
def playground(left: false, right: false)
1914
render current_component.new(
20-
page: page_proc.call(left, right),
21-
path: path_proc
15+
previous_page_url: left ? "#" : nil,
16+
next_page_url: right ? "#" : nil,
17+
turbo_frame_id: "pagination"
2218
)
2319
end
24-
25-
private
26-
27-
def page_proc
28-
lambda { |left, right|
29-
Struct.new(:number, :next_param, :first?, :last?).new(1, '#', !left, !right)
30-
}
31-
end
32-
33-
def path_proc
34-
->(_page_number) { "#" }
35-
end
3620
end

admin/spec/components/previews/solidus_admin/ui/table/pagination/component_preview/overview.html.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
<td class="font-bold px-3 py-1"><%= config[:title] %></td>
1010
<td class="px-3 py-1 text-center">
1111
<%= render current_component.new(
12-
page: page.call(config[:left], config[:right]),
13-
path: path
12+
previous_page_url: config[:left] ? "#" : nil,
13+
next_page_url: config[:right] ? "#" : nil,
14+
turbo_frame_id: "pagination"
1415
) %>
1516
</td>
1617
</tr>

0 commit comments

Comments
 (0)