From b986927e25ad86bbed227d85fb8f4bcf8ecb0aef Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 2 Oct 2025 15:54:02 +0200 Subject: [PATCH] Add pagination to the list of filtered cards --- app/helpers/pagination_helper.rb | 9 +++++++++ app/views/cards/index.html.erb | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb index 3fdbe4923..388c244dc 100644 --- a/app/helpers/pagination_helper.rb +++ b/app/helpers/pagination_helper.rb @@ -35,6 +35,15 @@ module PaginationHelper end end + def with_automatic_pagination(name, page, **properties) + pagination_list name, paginate_on_scroll: true, **properties do + concat(pagination_frame_tag(name, page) do + yield + concat link_to_next_page(name, page, activate_when_observed: true) + end) + end + end + def day_timeline_pagination_frame_tag(day_timeline, &) turbo_frame_tag day_timeline_pagination_frame_id_for(day_timeline.day), data: { timeline_target: "frame" }, role: "presentation", refresh: :morph, & end diff --git a/app/views/cards/index.html.erb b/app/views/cards/index.html.erb index 1e457c452..47d15dcb8 100644 --- a/app/views/cards/index.html.erb +++ b/app/views/cards/index.html.erb @@ -27,6 +27,8 @@ <%= turbo_frame_tag :cards_container do %>
- <%= render partial: "cards/display/preview", collection: @page.records, as: :card, locals: { draggable: true }, cached: ->(card) { cacheable_preview_parts_for(card) } %> + <%= with_automatic_pagination :cards_paginated_container, @page do %> + <%= render partial: "cards/display/preview", collection: @page.records, as: :card, locals: { draggable: true }, cached: ->(card) { cacheable_preview_parts_for(card) } %> + <% end %>
<% end %>