Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Revert "SD-1354 Add pagination to the view of product's variants"
Damian Legawiec702850fe92cb
diff --git a/backend/app/controllers/spree/admin/variants_controller.rb b/backend/app/controllers/spree/admin/variants_controller.rbindex f1850c1a1f..823240f848 100644--- a/backend/app/controllers/spree/admin/variants_controller.rb+++ b/backend/app/controllers/spree/admin/variants_controller.rb@@ -39,18 +39,15 @@ module Spreeenddef collection- return @collection if @collection.present?+ @deleted = params.key?(:deleted) && params[:deleted] == 'on' ? 'checked' : ''- params[:q] ||= {}- @deleted = params.dig(:q, :deleted_at_null) || '0'-- @collection = super- @collection = @collection.deleted if @deleted == '1'- # @search needs to be defined as this is passed to search_link- @search = @collection.ransack(params[:q])- @collection = @search.result.- page(params[:page]).- per(params[:per_page] || Spree::Config[:variants_per_page])+ @collection ||=+ if @deleted.blank?+ super.includes(:default_price, option_values: :option_type)+ else+ Variant.only_deleted.where(product_id: parent.id)+ end+ @collectionendprivatediff --git a/backend/app/views/spree/admin/variants/index.html.erb b/backend/app/views/spree/admin/variants/index.html.erbindex f7d1d014ed..9a9fff2ff3 100644--- a/backend/app/views/spree/admin/variants/index.html.erb+++ b/backend/app/views/spree/admin/variants/index.html.erb@@ -10,7 +10,7 @@<tr><th colspan="2"><%= Spree.t(:options) %></th><th><%= Spree.t(:price) %></th>- <th><%= sort_link @search, :sku, Spree.t(:sku) %></th>+ <th><%= Spree.t(:sku) %></th><th class="actions"></th></tr></thead>@@ -65,7 +65,6 @@<% content_for :page_actions do %><%= product_preview_link(@product) %><%= button_link_to(Spree.t(:new_variant), spree.new_admin_product_variant_url(@product), { icon: 'add.svg', :'data-update' => 'new_variant', class: 'btn-success', id: 'new_var_link' }) if can? :create, Spree::Variant %>- <%= button_link_to (@deleted == '1' ? Spree.t(:show_active) : Spree.t(:show_deleted)), spree.admin_product_variants_url(@product, { q: { deleted_at_null: @deleted == '1' ? "0" : "1" } }), { class: 'btn-outline-secondary', icon: 'filter.svg' } %>+ <%= button_link_to (@deleted.blank? ? Spree.t(:show_deleted) : Spree.t(:show_active)), spree.admin_product_variants_url(@product, deleted: @deleted.blank? ? "on" : "off"), { class: 'btn-outline-secondary', icon: 'filter.svg' } %><% end %><% end %>-<%= render partial: 'spree/admin/shared/index_table_options', locals: { collection: @collection } %>diff --git a/backend/spec/controllers/spree/admin/variants_controller_spec.rb b/backend/spec/controllers/spree/admin/variants_controller_spec.rbindex c0edb3cf40..342167a095 100644--- a/backend/spec/controllers/spree/admin/variants_controller_spec.rb+++ b/backend/spec/controllers/spree/admin/variants_controller_spec.rb@@ -22,7 +22,7 @@ module Spreebefore { variant_2.destroy }it 'assigns only deleted variants for a requested product' do- get :index, params: { product_id: product.slug, q: { deleted_at_null: '1' } }+ get :index, params: { product_id: product.slug, deleted: 'on' }expect(assigns(:collection)).not_to include variant_1expect(assigns(:collection)).to include variant_2enddiff --git a/core/app/models/spree/app_configuration.rb b/core/app/models/spree/app_configuration.rbindex e4aeb632e9..7458061611 100644--- a/core/app/models/spree/app_configuration.rb+++ b/core/app/models/spree/app_configuration.rb@@ -63,7 +63,6 @@ module Spreepreference :show_raw_product_description, :boolean, default: falsepreference :tax_using_ship_address, :boolean, default: truepreference :track_inventory_levels, :boolean, default: true # Determines whether to track on_hand values for variants / products.- preference :variants_per_page, :integer, default: Kaminari.config.default_per_page# Store credits configurationspreference :non_expiring_credit_types, :array, default: []