From eaddb65c15d4b1e0a92569361ffd5ad736416918 Mon Sep 17 00:00:00 2001 From: Rainer Dema Date: Thu, 21 Dec 2023 15:52:46 +0100 Subject: [PATCH] Use new ui/pages/index component in payment_methods/index component --- .../payment_methods/index/component.html.erb | 38 ------------------- .../payment_methods/index/component.rb | 38 ++++++++++++------- 2 files changed, 24 insertions(+), 52 deletions(-) delete mode 100644 admin/app/components/solidus_admin/payment_methods/index/component.html.erb 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 deleted file mode 100644 index c756e69f054..00000000000 --- a/admin/app/components/solidus_admin/payment_methods/index/component.html.erb +++ /dev/null @@ -1,38 +0,0 @@ -<%= page do %> - <%= page_header do %> - <%= page_header_title title %> - <%= page_header_actions do %> - <%= render component("ui/button").new( - tag: :a, - text: t('.add'), - href: spree.new_admin_payment_method_path, - icon: "add-line", - ) %> - <% end %> - <% end %> - - <%= render component('ui/table').new( - id: stimulus_id, - data: { - class: Spree::PaymentMethod, - 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, - }, - search: { - name: :q, - value: params[:q], - url: solidus_admin.payment_methods_path, - searchbar_key: :name_or_description_cont, - scopes: scopes, - filters: filters, - }, - sortable: { - url: ->(payment_method) { solidus_admin.move_payment_method_path(payment_method) }, - param: 'position', - }, - ) %> -<% end %> 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 13f4bbe8add..7044f36b712 100644 --- a/admin/app/components/solidus_admin/payment_methods/index/component.rb +++ b/admin/app/components/solidus_admin/payment_methods/index/component.rb @@ -1,22 +1,36 @@ # frozen_string_literal: true -class SolidusAdmin::PaymentMethods::Index::Component < SolidusAdmin::BaseComponent - include SolidusAdmin::Layout::PageHelpers +class SolidusAdmin::PaymentMethods::Index::Component < SolidusAdmin::UI::Pages::Index::Component + def model_class + Spree::PaymentMethod + end + + def search_key + :name_or_description_cont + end - def initialize(page:) - @page = page + def search_url + solidus_admin.payment_methods_path end - def title - Spree::PaymentMethod.model_name.human.pluralize + def row_url(payment_method) + spree.edit_admin_payment_method_path(payment_method) end - def prev_page_path - solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first? + def sortable_options + { + url: ->(payment_method) { solidus_admin.move_payment_method_path(payment_method) }, + param: 'position', + } end - def next_page_path - solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last? + def page_actions + render component("ui/button").new( + tag: :a, + text: t('.add'), + href: spree.new_admin_payment_method_path, + icon: "add-line", + ) end def batch_actions @@ -40,10 +54,6 @@ def scopes ] end - def filters - [] - end - def columns [ {