diff --git a/admin/app/components/solidus_admin/adjustment_reasons/index/component.html.erb b/admin/app/components/solidus_admin/adjustment_reasons/index/component.html.erb index 15a034f1eeb..47101b1ebe4 100644 --- a/admin/app/components/solidus_admin/adjustment_reasons/index/component.html.erb +++ b/admin/app/components/solidus_admin/adjustment_reasons/index/component.html.erb @@ -8,6 +8,7 @@ class: "align-self-end w-full", ) %> <% end %> + <%= render component('ui/table').new( id: stimulus_id, data: { @@ -24,8 +25,8 @@ value: params[:q], url: solidus_admin.adjustment_reasons_path, searchbar_key: :name_or_code_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb b/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb index e496b87ee65..039cbd27c8d 100644 --- a/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb +++ b/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb @@ -30,11 +30,11 @@ def batch_actions ] end - def filters + def scopes [] end - def scopes + def filters [] end diff --git a/admin/app/components/solidus_admin/layout/feedback/component.yml b/admin/app/components/solidus_admin/layout/feedback/component.yml index 4a4bd690d0f..39a501dda10 100644 --- a/admin/app/components/solidus_admin/layout/feedback/component.yml +++ b/admin/app/components/solidus_admin/layout/feedback/component.yml @@ -1,5 +1,3 @@ -# Add your component translations here. -# Use the translation in the example in your template with `t(".hello")`. en: give_feedback: 'Give feedback' feedback_description_html: 'We are constantly trying to improve.
Please let us know what you think about this admin page.' diff --git a/admin/app/components/solidus_admin/layout/navigation/account/component.rb b/admin/app/components/solidus_admin/layout/navigation/account/component.rb index 79c7308c471..00bd0d0bcdd 100644 --- a/admin/app/components/solidus_admin/layout/navigation/account/component.rb +++ b/admin/app/components/solidus_admin/layout/navigation/account/component.rb @@ -1,11 +1,6 @@ # frozen_string_literal: true -# Account navigation class SolidusAdmin::Layout::Navigation::Account::Component < SolidusAdmin::BaseComponent - # @param user_label [String] - # @param account_path [String] - # @param logout_path [String] - # @param logout_method [Symbol] def initialize(user_label:, account_path:, logout_path:, logout_method:) @user_label = user_label @account_path = account_path diff --git a/admin/app/components/solidus_admin/layout/navigation/component.rb b/admin/app/components/solidus_admin/layout/navigation/component.rb index aa39629eb28..56704ed936d 100644 --- a/admin/app/components/solidus_admin/layout/navigation/component.rb +++ b/admin/app/components/solidus_admin/layout/navigation/component.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# Renders the sidebar class SolidusAdmin::Layout::Navigation::Component < SolidusAdmin::BaseComponent def initialize( store:, diff --git a/admin/app/components/solidus_admin/layout/skip_link/component.rb b/admin/app/components/solidus_admin/layout/skip_link/component.rb index b0270d4b749..227e4fd57e8 100644 --- a/admin/app/components/solidus_admin/layout/skip_link/component.rb +++ b/admin/app/components/solidus_admin/layout/skip_link/component.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true -# Skip to content link class SolidusAdmin::Layout::SkipLink::Component < SolidusAdmin::BaseComponent - # @param href [String] the href attribute for the skip link def initialize(href:) @href = href end diff --git a/admin/app/components/solidus_admin/option_types/index/component.html.erb b/admin/app/components/solidus_admin/option_types/index/component.html.erb index 97eb469d2ac..29819fb60d4 100644 --- a/admin/app/components/solidus_admin/option_types/index/component.html.erb +++ b/admin/app/components/solidus_admin/option_types/index/component.html.erb @@ -12,11 +12,13 @@ <% end %> <%= render component('ui/table').new( - id: 'option-types-list', + id: stimulus_id, data: { class: Spree::OptionType, - rows: @option_types, + rows: @page.records, url: ->(option_type) { spree.edit_admin_option_type_path(option_type) }, + prev: prev_page_path, + next: next_page_path, columns: columns, batch_actions: batch_actions, }, diff --git a/admin/app/components/solidus_admin/option_types/index/component.rb b/admin/app/components/solidus_admin/option_types/index/component.rb index b46f909edc6..f98d454a7a6 100644 --- a/admin/app/components/solidus_admin/option_types/index/component.rb +++ b/admin/app/components/solidus_admin/option_types/index/component.rb @@ -3,14 +3,33 @@ class SolidusAdmin::OptionTypes::Index::Component < SolidusAdmin::BaseComponent include SolidusAdmin::Layout::PageHelpers - def initialize(option_types:) - @option_types = option_types + def initialize(page:) + @page = page end def title Spree::OptionType.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 + [ + { + display_name: t('.batch_actions.delete'), + action: solidus_admin.option_types_path, + method: :delete, + icon: 'delete-bin-7-line', + }, + ] + end + def columns [ name_column, @@ -35,15 +54,4 @@ def presentation_column end } end - - def batch_actions - [ - { - display_name: t('.batch_actions.delete'), - action: solidus_admin.option_types_path, - method: :delete, - icon: 'delete-bin-7-line', - }, - ] - end end diff --git a/admin/app/components/solidus_admin/orders/cart/component.yml b/admin/app/components/solidus_admin/orders/cart/component.yml index 7bf7a242a5c..c9ab43bdd3d 100644 --- a/admin/app/components/solidus_admin/orders/cart/component.yml +++ b/admin/app/components/solidus_admin/orders/cart/component.yml @@ -1,5 +1,3 @@ -# Add your component translations here. -# Use the translation in the example in your template with `t(".hello")`. en: title: "Cart" search_placeholder: "Find a variant by name or SKU" diff --git a/admin/app/components/solidus_admin/orders/index/component.html.erb b/admin/app/components/solidus_admin/orders/index/component.html.erb index f6d31446202..3f66b26df60 100644 --- a/admin/app/components/solidus_admin/orders/index/component.html.erb +++ b/admin/app/components/solidus_admin/orders/index/component.html.erb @@ -1,21 +1,18 @@ -
-
-

- <%= title %> -

- -
+<%= page do %> + <%= page_header do %> + <%= page_header_title title %> + <%= page_header_actions do %> <%= render component("ui/button").new( tag: :a, text: t('.create_order'), href: spree.new_admin_order_path, icon: "add-line", ) %> -
-
+ <% end %> + <% end %> <%= render component('ui/table').new( - id: 'orders-list', + id: stimulus_id, data: { class: Spree::Order, rows: @page.records, @@ -31,8 +28,8 @@ value: params[:q], searchbar_key: :number_or_shipments_number_or_bill_address_name_or_email_cont, url: solidus_admin.orders_path(scope: params[:scope]), - filters: filters, scopes: scopes, + filters: filters, }, ) %> -
+<% end %> diff --git a/admin/app/components/solidus_admin/orders/index/component.rb b/admin/app/components/solidus_admin/orders/index/component.rb index 17e8eca8bd3..25033a23738 100644 --- a/admin/app/components/solidus_admin/orders/index/component.rb +++ b/admin/app/components/solidus_admin/orders/index/component.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent + include SolidusAdmin::Layout::PageHelpers + def initialize(page:) @page = page end diff --git a/admin/app/components/solidus_admin/orders/index/component.yml b/admin/app/components/solidus_admin/orders/index/component.yml index f3c4d5bbb12..bcfbf6c6b69 100644 --- a/admin/app/components/solidus_admin/orders/index/component.yml +++ b/admin/app/components/solidus_admin/orders/index/component.yml @@ -1,5 +1,3 @@ -# Add your component translations here. -# Use the translation in the example in your template with `t(".hello")`. en: create_order: 'Create Order' columns: diff --git a/admin/app/components/solidus_admin/orders/show/address/component.yml b/admin/app/components/solidus_admin/orders/show/address/component.yml index d7c82068537..4d9d520d688 100644 --- a/admin/app/components/solidus_admin/orders/show/address/component.yml +++ b/admin/app/components/solidus_admin/orders/show/address/component.yml @@ -1,5 +1,3 @@ -# Add your component translations here. -# Use the translation in the example in your template with `t(".hello")`. en: save: Save cancel: Cancel diff --git a/admin/app/components/solidus_admin/orders/show/component.js b/admin/app/components/solidus_admin/orders/show/component.js index 567f287fd66..8de1e56f478 100644 --- a/admin/app/components/solidus_admin/orders/show/component.js +++ b/admin/app/components/solidus_admin/orders/show/component.js @@ -2,6 +2,6 @@ import { Controller } from '@hotwired/stimulus' export default class extends Controller { closeMenus() { - this.element.querySelectorAll('details').forEach(details => details.removeAttribute('open')); + this.element.querySelectorAll('details').forEach(details => details.removeAttribute('open')) } } diff --git a/admin/app/components/solidus_admin/orders/show/component.yml b/admin/app/components/solidus_admin/orders/show/component.yml index 4ad65648bc8..497a0186ab2 100644 --- a/admin/app/components/solidus_admin/orders/show/component.yml +++ b/admin/app/components/solidus_admin/orders/show/component.yml @@ -1,5 +1,3 @@ -# Add your component translations here. -# Use the translation in the example in your template with `t(".hello")`. en: save: Save discard: Discard 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 33b7c29e13c..86fa120c552 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 @@ -26,6 +26,7 @@ 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) }, 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 230a128f8b5..54a1a5b8b04 100644 --- a/admin/app/components/solidus_admin/payment_methods/index/component.rb +++ b/admin/app/components/solidus_admin/payment_methods/index/component.rb @@ -32,6 +32,10 @@ def scopes ] end + def filters + [] + end + def columns [ { diff --git a/admin/app/components/solidus_admin/products/index/component.html.erb b/admin/app/components/solidus_admin/products/index/component.html.erb index 7ded5d68626..312a613a1fe 100644 --- a/admin/app/components/solidus_admin/products/index/component.html.erb +++ b/admin/app/components/solidus_admin/products/index/component.html.erb @@ -12,7 +12,7 @@ <% end %> <%= render component('ui/table').new( - id: 'products-list', + id: stimulus_id, data: { class: Spree::Product, rows: @page.records, @@ -27,8 +27,8 @@ value: params[:q], url: solidus_admin.products_path, searchbar_key: :name_or_variants_including_master_sku_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/products/index/component.rb b/admin/app/components/solidus_admin/products/index/component.rb index 1b07040675f..74ef36f62c1 100644 --- a/admin/app/components/solidus_admin/products/index/component.rb +++ b/admin/app/components/solidus_admin/products/index/component.rb @@ -42,6 +42,17 @@ def batch_actions ] end + def scopes + [ + { name: :all, label: t('.scopes.all'), default: true }, + { name: :in_stock, label: t('.scopes.in_stock') }, + { name: :out_of_stock, label: t('.scopes.out_of_stock') }, + { name: :available, label: t('.scopes.available') }, + { name: :discontinued, label: t('.scopes.discontinued') }, + { name: :deleted, label: t('.scopes.deleted') }, + ] + end + def filters Spree::OptionType.all.map do |option_type| { @@ -54,17 +65,6 @@ def filters end end - def scopes - [ - { name: :all, label: t('.scopes.all'), default: true }, - { name: :in_stock, label: t('.scopes.in_stock') }, - { name: :out_of_stock, label: t('.scopes.out_of_stock') }, - { name: :available, label: t('.scopes.available') }, - { name: :discontinued, label: t('.scopes.discontinued') }, - { name: :deleted, label: t('.scopes.deleted') }, - ] - end - def columns [ image_column, diff --git a/admin/app/components/solidus_admin/promotion_categories/index/component.html.erb b/admin/app/components/solidus_admin/promotion_categories/index/component.html.erb index fa5e9dffe96..84be1f3128b 100644 --- a/admin/app/components/solidus_admin/promotion_categories/index/component.html.erb +++ b/admin/app/components/solidus_admin/promotion_categories/index/component.html.erb @@ -12,11 +12,13 @@ <% end %> <%= render component('ui/table').new( - id: 'promotion-categories-list', + id: stimulus_id, data: { class: Spree::PromotionCategory, - rows: @promotion_categories, + rows: @page.records, url: ->(promotion_category) { spree.edit_admin_promotion_category_path(promotion_category) }, + prev: prev_page_path, + next: next_page_path, columns: columns, batch_actions: batch_actions, }, diff --git a/admin/app/components/solidus_admin/promotion_categories/index/component.rb b/admin/app/components/solidus_admin/promotion_categories/index/component.rb index 78371004562..4a20c7d1db8 100644 --- a/admin/app/components/solidus_admin/promotion_categories/index/component.rb +++ b/admin/app/components/solidus_admin/promotion_categories/index/component.rb @@ -3,14 +3,33 @@ class SolidusAdmin::PromotionCategories::Index::Component < SolidusAdmin::BaseComponent include SolidusAdmin::Layout::PageHelpers - def initialize(promotion_categories:) - @promotion_categories = promotion_categories + def initialize(page:) + @page = page end def title Spree::PromotionCategory.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 + [ + { + display_name: t('.batch_actions.delete'), + action: solidus_admin.promotion_categories_path, + method: :delete, + icon: 'delete-bin-7-line', + }, + ] + end + def columns [ name_column, @@ -35,15 +54,4 @@ def code_column end } end - - def batch_actions - [ - { - display_name: t('.batch_actions.delete'), - action: solidus_admin.promotion_categories_path, - method: :delete, - icon: 'delete-bin-7-line', - }, - ] - end end diff --git a/admin/app/components/solidus_admin/promotions/index/component.html.erb b/admin/app/components/solidus_admin/promotions/index/component.html.erb index 3740d4acbd0..2e43eb92892 100644 --- a/admin/app/components/solidus_admin/promotions/index/component.html.erb +++ b/admin/app/components/solidus_admin/promotions/index/component.html.erb @@ -27,8 +27,8 @@ value: params[:q], url: solidus_admin.promotions_path, searchbar_key: :name_or_codes_value_or_path_or_description_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/promotions/index/component.rb b/admin/app/components/solidus_admin/promotions/index/component.rb index b80a42bf3e9..60a2dd0cc7e 100644 --- a/admin/app/components/solidus_admin/promotions/index/component.rb +++ b/admin/app/components/solidus_admin/promotions/index/component.rb @@ -30,6 +30,16 @@ def batch_actions ] end + def scopes + [ + { name: :active, label: t('.scopes.active'), default: true }, + { name: :draft, label: t('.scopes.draft') }, + { name: :future, label: t('.scopes.future') }, + { name: :expired, label: t('.scopes.expired') }, + { name: :all, label: t('.scopes.all') }, + ] + end + def filters [ { @@ -41,16 +51,6 @@ def filters ] end - def scopes - [ - { name: :active, label: t('.scopes.active'), default: true }, - { name: :draft, label: t('.scopes.draft') }, - { name: :future, label: t('.scopes.future') }, - { name: :expired, label: t('.scopes.expired') }, - { name: :all, label: t('.scopes.all') }, - ] - end - def columns [ { diff --git a/admin/app/components/solidus_admin/properties/index/component.html.erb b/admin/app/components/solidus_admin/properties/index/component.html.erb index 4304bf4d572..bc8ad4e511f 100644 --- a/admin/app/components/solidus_admin/properties/index/component.html.erb +++ b/admin/app/components/solidus_admin/properties/index/component.html.erb @@ -12,7 +12,7 @@ <% end %> <%= render component('ui/table').new( - id: 'property-list', + id: stimulus_id, data: { class: Spree::Property, rows: @page.records, @@ -27,6 +27,8 @@ value: params[:q], url: solidus_admin.properties_path, searchbar_key: :name_cont, + scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/properties/index/component.rb b/admin/app/components/solidus_admin/properties/index/component.rb index 953ac5ca1a3..9bc2b810c13 100644 --- a/admin/app/components/solidus_admin/properties/index/component.rb +++ b/admin/app/components/solidus_admin/properties/index/component.rb @@ -30,6 +30,14 @@ def batch_actions ] end + def scopes + [] + end + + def filters + [] + end + def columns [ name_column, diff --git a/admin/app/components/solidus_admin/refund_reasons/index/component.html.erb b/admin/app/components/solidus_admin/refund_reasons/index/component.html.erb index f08f077d39c..c29b71d03ef 100644 --- a/admin/app/components/solidus_admin/refund_reasons/index/component.html.erb +++ b/admin/app/components/solidus_admin/refund_reasons/index/component.html.erb @@ -24,8 +24,8 @@ value: params[:q], url: solidus_admin.refund_reasons_path, searchbar_key: :name_or_code_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/refund_reasons/index/component.rb b/admin/app/components/solidus_admin/refund_reasons/index/component.rb index 7a039132cc9..e6570eb31e7 100644 --- a/admin/app/components/solidus_admin/refund_reasons/index/component.rb +++ b/admin/app/components/solidus_admin/refund_reasons/index/component.rb @@ -30,11 +30,11 @@ def batch_actions ] end - def filters + def scopes [] end - def scopes + def filters [] end diff --git a/admin/app/components/solidus_admin/reimbursement_types/index/component.html.erb b/admin/app/components/solidus_admin/reimbursement_types/index/component.html.erb index 2c55c0c0f62..675fa8637a2 100644 --- a/admin/app/components/solidus_admin/reimbursement_types/index/component.html.erb +++ b/admin/app/components/solidus_admin/reimbursement_types/index/component.html.erb @@ -15,8 +15,8 @@ value: params[:q], url: solidus_admin.reimbursement_types_path, searchbar_key: :name_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/reimbursement_types/index/component.rb b/admin/app/components/solidus_admin/reimbursement_types/index/component.rb index d2be4c44d92..6465f133e11 100644 --- a/admin/app/components/solidus_admin/reimbursement_types/index/component.rb +++ b/admin/app/components/solidus_admin/reimbursement_types/index/component.rb @@ -23,11 +23,11 @@ def batch_actions [] end - def filters + def scopes [] end - def scopes + def filters [] end diff --git a/admin/app/components/solidus_admin/return_reasons/index/component.html.erb b/admin/app/components/solidus_admin/return_reasons/index/component.html.erb index 9bb9c158696..d65f815f2d8 100644 --- a/admin/app/components/solidus_admin/return_reasons/index/component.html.erb +++ b/admin/app/components/solidus_admin/return_reasons/index/component.html.erb @@ -24,8 +24,8 @@ value: params[:q], url: solidus_admin.return_reasons_path, searchbar_key: :name_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/return_reasons/index/component.rb b/admin/app/components/solidus_admin/return_reasons/index/component.rb index ae709ce96da..8026101dec0 100644 --- a/admin/app/components/solidus_admin/return_reasons/index/component.rb +++ b/admin/app/components/solidus_admin/return_reasons/index/component.rb @@ -30,11 +30,11 @@ def batch_actions ] end - def filters + def scopes [] end - def scopes + def filters [] end diff --git a/admin/app/components/solidus_admin/shipping_categories/index/component.html.erb b/admin/app/components/solidus_admin/shipping_categories/index/component.html.erb index 9afe630b8ae..8745df4afd0 100644 --- a/admin/app/components/solidus_admin/shipping_categories/index/component.html.erb +++ b/admin/app/components/solidus_admin/shipping_categories/index/component.html.erb @@ -25,8 +25,8 @@ value: params[:q], url: solidus_admin.shipping_categories_path, searchbar_key: :name_or_description_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/shipping_categories/index/component.rb b/admin/app/components/solidus_admin/shipping_categories/index/component.rb index 74577cae898..6883cbf3a8d 100644 --- a/admin/app/components/solidus_admin/shipping_categories/index/component.rb +++ b/admin/app/components/solidus_admin/shipping_categories/index/component.rb @@ -30,11 +30,11 @@ def batch_actions ] end - def filters + def scopes [] end - def scopes + def filters [] end diff --git a/admin/app/components/solidus_admin/shipping_methods/index/component.html.erb b/admin/app/components/solidus_admin/shipping_methods/index/component.html.erb index 6bb417a7e87..66015aa09b2 100644 --- a/admin/app/components/solidus_admin/shipping_methods/index/component.html.erb +++ b/admin/app/components/solidus_admin/shipping_methods/index/component.html.erb @@ -25,8 +25,8 @@ value: params[:q], url: solidus_admin.shipping_methods_path, searchbar_key: :name_or_description_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/shipping_methods/index/component.rb b/admin/app/components/solidus_admin/shipping_methods/index/component.rb index ef6fd28f8e9..0697a4a5de5 100644 --- a/admin/app/components/solidus_admin/shipping_methods/index/component.rb +++ b/admin/app/components/solidus_admin/shipping_methods/index/component.rb @@ -30,11 +30,11 @@ def batch_actions ] end - def filters + def scopes [] end - def scopes + def filters [] end diff --git a/admin/app/components/solidus_admin/stock_items/index/component.html.erb b/admin/app/components/solidus_admin/stock_items/index/component.html.erb index 6752779bb31..ac0a951f8b0 100644 --- a/admin/app/components/solidus_admin/stock_items/index/component.html.erb +++ b/admin/app/components/solidus_admin/stock_items/index/component.html.erb @@ -3,8 +3,7 @@ <%= page_header_title title %> <% end %> - <%= - render component('ui/table').new( + <%= render component('ui/table').new( id: stimulus_id, data: { class: Spree::StockItem, @@ -20,8 +19,8 @@ value: permitted_query_params, url: solidus_admin.stock_items_path, searchbar_key: :variant_product_name_or_variant_sku_or_variant_option_values_name_or_variant_option_values_presentation_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/stock_locations/index/component.html.erb b/admin/app/components/solidus_admin/stock_locations/index/component.html.erb index b127f86ba5c..ebd7cc78d56 100644 --- a/admin/app/components/solidus_admin/stock_locations/index/component.html.erb +++ b/admin/app/components/solidus_admin/stock_locations/index/component.html.erb @@ -25,8 +25,8 @@ value: params[:q], url: solidus_admin.stock_locations_path, searchbar_key: :name_or_description_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/stock_locations/index/component.rb b/admin/app/components/solidus_admin/stock_locations/index/component.rb index 4ea95405227..7ed1bda5164 100644 --- a/admin/app/components/solidus_admin/stock_locations/index/component.rb +++ b/admin/app/components/solidus_admin/stock_locations/index/component.rb @@ -30,11 +30,11 @@ def batch_actions ] end - def filters + def scopes [] end - def scopes + def filters [] end diff --git a/admin/app/components/solidus_admin/store_credit_reasons/index/component.html.erb b/admin/app/components/solidus_admin/store_credit_reasons/index/component.html.erb index a4e56ee9501..f70bb34932b 100644 --- a/admin/app/components/solidus_admin/store_credit_reasons/index/component.html.erb +++ b/admin/app/components/solidus_admin/store_credit_reasons/index/component.html.erb @@ -24,8 +24,8 @@ value: params[:q], url: solidus_admin.store_credit_reasons_path, searchbar_key: :name_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb b/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb index 18898313bac..d0373358af1 100644 --- a/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb +++ b/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb @@ -30,11 +30,11 @@ def batch_actions ] end - def filters + def scopes [] end - def scopes + def filters [] end diff --git a/admin/app/components/solidus_admin/stores/index/component.html.erb b/admin/app/components/solidus_admin/stores/index/component.html.erb index fcd454b2e0b..d179f04ccb5 100644 --- a/admin/app/components/solidus_admin/stores/index/component.html.erb +++ b/admin/app/components/solidus_admin/stores/index/component.html.erb @@ -27,8 +27,8 @@ value: params[:q], url: solidus_admin.stores_path, searchbar_key: :name_or_url_or_code_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/stores/index/component.rb b/admin/app/components/solidus_admin/stores/index/component.rb index 486dee8d77c..14a6bff249e 100644 --- a/admin/app/components/solidus_admin/stores/index/component.rb +++ b/admin/app/components/solidus_admin/stores/index/component.rb @@ -30,11 +30,11 @@ def batch_actions ] end - def filters + def scopes [] end - def scopes + def filters [] end diff --git a/admin/app/components/solidus_admin/tax_categories/index/component.html.erb b/admin/app/components/solidus_admin/tax_categories/index/component.html.erb index 4d17aedb16e..1ca843e0663 100644 --- a/admin/app/components/solidus_admin/tax_categories/index/component.html.erb +++ b/admin/app/components/solidus_admin/tax_categories/index/component.html.erb @@ -25,8 +25,8 @@ value: params[:q], url: solidus_admin.tax_categories_path, searchbar_key: :name_or_description_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/tax_categories/index/component.rb b/admin/app/components/solidus_admin/tax_categories/index/component.rb index 252f146b01c..897a585e672 100644 --- a/admin/app/components/solidus_admin/tax_categories/index/component.rb +++ b/admin/app/components/solidus_admin/tax_categories/index/component.rb @@ -30,11 +30,11 @@ def batch_actions ] end - def filters + def scopes [] end - def scopes + def filters [] end diff --git a/admin/app/components/solidus_admin/tax_rates/index/component.html.erb b/admin/app/components/solidus_admin/tax_rates/index/component.html.erb index f4149e0c475..305c10bf791 100644 --- a/admin/app/components/solidus_admin/tax_rates/index/component.html.erb +++ b/admin/app/components/solidus_admin/tax_rates/index/component.html.erb @@ -25,8 +25,8 @@ value: params[:q], url: solidus_admin.tax_rates_path, searchbar_key: :name_or_description_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/tax_rates/index/component.rb b/admin/app/components/solidus_admin/tax_rates/index/component.rb index d65f7130068..8d9b7bae803 100644 --- a/admin/app/components/solidus_admin/tax_rates/index/component.rb +++ b/admin/app/components/solidus_admin/tax_rates/index/component.rb @@ -30,6 +30,10 @@ def batch_actions ] end + def scopes + [] + end + def filters [ { @@ -47,10 +51,6 @@ def filters ] end - def scopes - [] - end - def columns [ { diff --git a/admin/app/components/solidus_admin/taxonomies/index/component.html.erb b/admin/app/components/solidus_admin/taxonomies/index/component.html.erb index bd43b5e5675..dd1a03e1ff6 100644 --- a/admin/app/components/solidus_admin/taxonomies/index/component.html.erb +++ b/admin/app/components/solidus_admin/taxonomies/index/component.html.erb @@ -12,10 +12,10 @@ <% end %> <%= render component('ui/table').new( - id: 'taxonomies-list', + id: stimulus_id, data: { class: Spree::Taxonomy, - rows: @taxonomies, + rows: @page.records, url: ->(taxonomy) { spree.edit_admin_taxonomy_path(taxonomy) }, columns: columns, batch_actions: batch_actions, diff --git a/admin/app/components/solidus_admin/taxonomies/index/component.rb b/admin/app/components/solidus_admin/taxonomies/index/component.rb index d7ce3c48f75..8841631209e 100644 --- a/admin/app/components/solidus_admin/taxonomies/index/component.rb +++ b/admin/app/components/solidus_admin/taxonomies/index/component.rb @@ -3,27 +3,20 @@ class SolidusAdmin::Taxonomies::Index::Component < SolidusAdmin::BaseComponent include SolidusAdmin::Layout::PageHelpers - def initialize(taxonomies:) - @taxonomies = taxonomies + def initialize(page:) + @page = page end def title Spree::Taxonomy.model_name.human.pluralize end - def columns - [ - name_column, - ] + def prev_page_path + solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first? end - def name_column - { - header: :name, - data: ->(taxonomy) do - content_tag :div, taxonomy.name - 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 @@ -36,4 +29,19 @@ def batch_actions }, ] end + + def columns + [ + name_column, + ] + end + + def name_column + { + header: :name, + data: ->(taxonomy) do + content_tag :div, taxonomy.name + end + } + end end diff --git a/admin/app/components/solidus_admin/ui/table/component.rb b/admin/app/components/solidus_admin/ui/table/component.rb index 747a6524f61..0bf5536b0a5 100644 --- a/admin/app/components/solidus_admin/ui/table/component.rb +++ b/admin/app/components/solidus_admin/ui/table/component.rb @@ -23,7 +23,7 @@ def plural_name end end - class Search < Struct.new(:name, :value, :url, :searchbar_key, :filters, :scopes, keyword_init: true) # rubocop:disable Style/StructInheritance + class Search < Struct.new(:name, :value, :url, :searchbar_key, :scopes, :filters, keyword_init: true) # rubocop:disable Style/StructInheritance def initialize(**args) super diff --git a/admin/app/components/solidus_admin/ui/table/ransack_filter/component.yml b/admin/app/components/solidus_admin/ui/table/ransack_filter/component.yml index cac8d2c2b8f..5ac2221c6bf 100644 --- a/admin/app/components/solidus_admin/ui/table/ransack_filter/component.yml +++ b/admin/app/components/solidus_admin/ui/table/ransack_filter/component.yml @@ -1,5 +1,3 @@ -# Add your component translations here. -# Use the translation in the example in your template with `t(".hello")`. en: search: Search no_filter_options: No options available diff --git a/admin/app/components/solidus_admin/users/index/component.html.erb b/admin/app/components/solidus_admin/users/index/component.html.erb index 192dd4ce16a..fb69176fabf 100644 --- a/admin/app/components/solidus_admin/users/index/component.html.erb +++ b/admin/app/components/solidus_admin/users/index/component.html.erb @@ -27,8 +27,8 @@ value: params[:q], url: solidus_admin.users_path, searchbar_key: :email_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/users/index/component.rb b/admin/app/components/solidus_admin/users/index/component.rb index 3965253e481..359ae861a2f 100644 --- a/admin/app/components/solidus_admin/users/index/component.rb +++ b/admin/app/components/solidus_admin/users/index/component.rb @@ -30,6 +30,16 @@ def batch_actions ] end + def scopes + [ + { name: :customers, label: t('.scopes.customers'), default: true }, + { name: :admin, label: t('.scopes.admin') }, + { name: :with_orders, label: t('.scopes.with_orders') }, + { name: :without_orders, label: t('.scopes.without_orders') }, + { name: :all, label: t('.scopes.all') }, + ] + end + def filters [ { @@ -41,16 +51,6 @@ def filters ] end - def scopes - [ - { name: :customers, label: t('.scopes.customers'), default: true }, - { name: :admin, label: t('.scopes.admin') }, - { name: :with_orders, label: t('.scopes.with_orders') }, - { name: :without_orders, label: t('.scopes.without_orders') }, - { name: :all, label: t('.scopes.all') }, - ] - end - def columns [ { diff --git a/admin/app/components/solidus_admin/zones/index/component.html.erb b/admin/app/components/solidus_admin/zones/index/component.html.erb index 8842a5177e2..1162d7d7fbe 100644 --- a/admin/app/components/solidus_admin/zones/index/component.html.erb +++ b/admin/app/components/solidus_admin/zones/index/component.html.erb @@ -28,8 +28,8 @@ value: params[:q], url: solidus_admin.zones_path, searchbar_key: :name_or_description_cont, - filters: filters, scopes: scopes, + filters: filters, }, ) %> <% end %> diff --git a/admin/app/components/solidus_admin/zones/index/component.rb b/admin/app/components/solidus_admin/zones/index/component.rb index f7f7b5066da..fe5d7e58f8b 100644 --- a/admin/app/components/solidus_admin/zones/index/component.rb +++ b/admin/app/components/solidus_admin/zones/index/component.rb @@ -30,11 +30,11 @@ def batch_actions ] end - def filters + def scopes [] end - def scopes + def filters [] end diff --git a/admin/app/controllers/solidus_admin/option_types_controller.rb b/admin/app/controllers/solidus_admin/option_types_controller.rb index 338a65d003d..444f1bbbafa 100644 --- a/admin/app/controllers/solidus_admin/option_types_controller.rb +++ b/admin/app/controllers/solidus_admin/option_types_controller.rb @@ -2,13 +2,20 @@ module SolidusAdmin class OptionTypesController < SolidusAdmin::BaseController + include SolidusAdmin::ControllerHelpers::Search + before_action :load_option_type, only: [:move] def index - @option_types = Spree::OptionType.all + option_types = apply_search_to( + Spree::OptionType.all, + param: :q, + ) + + set_page_and_extract_portion_from(option_types) respond_to do |format| - format.html { render component('option_types/index').new(option_types: @option_types) } + format.html { render component('option_types/index').new(page: @page) } end end diff --git a/admin/app/controllers/solidus_admin/products_controller.rb b/admin/app/controllers/solidus_admin/products_controller.rb index 29443ed7a64..a085ef0d41c 100644 --- a/admin/app/controllers/solidus_admin/products_controller.rb +++ b/admin/app/controllers/solidus_admin/products_controller.rb @@ -13,7 +13,7 @@ class ProductsController < SolidusAdmin::BaseController def index products = apply_search_to( - Spree::Product.includes(:master, variants: :default_price), + Spree::Product.includes(:master, :variants), param: :q, ) diff --git a/admin/app/controllers/solidus_admin/promotion_categories_controller.rb b/admin/app/controllers/solidus_admin/promotion_categories_controller.rb index fe693d95225..e258cc7609b 100644 --- a/admin/app/controllers/solidus_admin/promotion_categories_controller.rb +++ b/admin/app/controllers/solidus_admin/promotion_categories_controller.rb @@ -2,13 +2,20 @@ module SolidusAdmin class PromotionCategoriesController < SolidusAdmin::BaseController + include SolidusAdmin::ControllerHelpers::Search + before_action :load_promotion_category, only: [:move] def index - @promotion_categories = Spree::PromotionCategory.all + promotion_categories = apply_search_to( + Spree::PromotionCategory.all, + param: :q, + ) + + set_page_and_extract_portion_from(promotion_categories) respond_to do |format| - format.html { render component('promotion_categories/index').new(promotion_categories: @promotion_categories) } + format.html { render component('promotion_categories/index').new(page: @page) } end end diff --git a/admin/app/controllers/solidus_admin/taxonomies_controller.rb b/admin/app/controllers/solidus_admin/taxonomies_controller.rb index c3e87055158..fb0387d075a 100644 --- a/admin/app/controllers/solidus_admin/taxonomies_controller.rb +++ b/admin/app/controllers/solidus_admin/taxonomies_controller.rb @@ -2,13 +2,20 @@ module SolidusAdmin class TaxonomiesController < SolidusAdmin::BaseController + include SolidusAdmin::ControllerHelpers::Search + before_action :load_taxonomy, only: [:move] def index - @taxonomies = Spree::Taxonomy.all + taxonomies = apply_search_to( + Spree::Taxonomy.all, + param: :q, + ) + + set_page_and_extract_portion_from(taxonomies) respond_to do |format| - format.html { render component('taxonomies/index').new(taxonomies: @taxonomies) } + format.html { render component('taxonomies/index').new(page: @page) } end end diff --git a/admin/config/locales/menu_item.en.yml b/admin/config/locales/menu_item.en.yml index 4fd38dbeb5c..a67409fce7d 100644 --- a/admin/config/locales/menu_item.en.yml +++ b/admin/config/locales/menu_item.en.yml @@ -4,10 +4,16 @@ en: orders: Orders products: Products option_types: Option Types - property_types: Property Types + property_types: Properties taxonomies: Taxonomies taxons: Display Order promotions: Promotions + promotion_categories: Promotion Categories stock: Stock users: Users settings: Settings + stores: Stores + taxes: Taxes + checkout: Refunds and Returns + shipping: Shipping + zones: Zones