diff --git a/admin/app/components/solidus_admin/payment_methods/index/component.html.erb b/admin/app/components/solidus_admin/payment_methods/index/component.html.erb index 86fa120c552..c756e69f054 100644 --- a/admin/app/components/solidus_admin/payment_methods/index/component.html.erb +++ b/admin/app/components/solidus_admin/payment_methods/index/component.html.erb @@ -15,7 +15,9 @@ id: stimulus_id, data: { class: Spree::PaymentMethod, - rows: @payment_methods, + rows: @page.records, + prev: prev_page_path, + next: next_page_path, url: ->(payment_method) { spree.edit_admin_payment_method_path(payment_method) }, columns: columns, batch_actions: batch_actions, diff --git a/admin/app/components/solidus_admin/payment_methods/index/component.rb b/admin/app/components/solidus_admin/payment_methods/index/component.rb index 54a1a5b8b04..13f4bbe8add 100644 --- a/admin/app/components/solidus_admin/payment_methods/index/component.rb +++ b/admin/app/components/solidus_admin/payment_methods/index/component.rb @@ -3,14 +3,22 @@ class SolidusAdmin::PaymentMethods::Index::Component < SolidusAdmin::BaseComponent include SolidusAdmin::Layout::PageHelpers - def initialize(payment_methods:) - @payment_methods = payment_methods + def initialize(page:) + @page = page end def title Spree::PaymentMethod.model_name.human.pluralize end + def prev_page_path + solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first? + end + + def next_page_path + solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last? + end + def batch_actions [ { diff --git a/admin/app/controllers/solidus_admin/payment_methods_controller.rb b/admin/app/controllers/solidus_admin/payment_methods_controller.rb index 23056b9e2c9..684eb7381f3 100644 --- a/admin/app/controllers/solidus_admin/payment_methods_controller.rb +++ b/admin/app/controllers/solidus_admin/payment_methods_controller.rb @@ -13,13 +13,15 @@ class PaymentMethodsController < SolidusAdmin::BaseController search_scope(:admin, &:available_to_admin) def index - @payment_methods = apply_search_to( + payment_methods = apply_search_to( Spree::PaymentMethod.ordered_by_position, param: :q, ) + set_page_and_extract_portion_from(payment_methods) + respond_to do |format| - format.html { render component('payment_methods/index').new(payment_methods: @payment_methods) } + format.html { render component('payment_methods/index').new(page: @page) } end end