diff --git a/Gemfile b/Gemfile index 5aa392922e..d4f45e4d28 100644 --- a/Gemfile +++ b/Gemfile @@ -55,7 +55,7 @@ group :development do gem 'solargraph' end -spree_opts = { github: 'spree/spree', branch: 'main' } +spree_opts = { github: 'spree/spree', branch: '4-4-stable' } gem 'spree_core', spree_opts gem 'spree_api', spree_opts diff --git a/app/assets/javascripts/spree/backend/address_states.es6 b/app/assets/javascripts/spree/backend/address_states.es6 index 781704a480..6ba7ac5ef3 100644 --- a/app/assets/javascripts/spree/backend/address_states.es6 +++ b/app/assets/javascripts/spree/backend/address_states.es6 @@ -4,6 +4,8 @@ function updateAddressState(region, successCallback) { const stateSelect = $('#' + region + 'state select') const stateInput = $('#' + region + 'state input.state_name') + if (!countryId) { return } + fetch(Spree.routes.countries_api_v2 + '/' + countryId + '?include=states', { headers: Spree.apiV2Authentication() }).then((response) => { diff --git a/app/assets/javascripts/spree/backend/global/flatpickr.es6 b/app/assets/javascripts/spree/backend/global/flatpickr.es6 index ebe0b82614..cdf033f063 100644 --- a/app/assets/javascripts/spree/backend/global/flatpickr.es6 +++ b/app/assets/javascripts/spree/backend/global/flatpickr.es6 @@ -21,3 +21,9 @@ document.addEventListener("spree:load", function() { flatpickr('.datepicker', {}) }) +document.addEventListener("turbo:before-cache", function() { + document.querySelectorAll('.datePickerFrom, .datePickerTo, .datepicker').forEach(function(element) { + element._flatpickr.destroy() + }) +}) + diff --git a/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 b/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 index 5e08e33c3b..925ba9e475 100644 --- a/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 +++ b/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 @@ -25,6 +25,13 @@ document.addEventListener("spree:load", function() { loadAutoCompleteParams() }) +// we need to delete select2 instances before document is saved to cache +// https://stackoverflow.com/questions/36497723/select2-with-ajax-gets-initialized-several-times-with-rails-turbolinks-events +document.addEventListener("turbo:before-cache", function() { + const select2Autocompletes = document.querySelectorAll('select[data-autocomplete-url-value]') + select2Autocompletes.forEach(element => $(element).select2('destroy')) +}) + // eslint-disable-next-line no-unused-vars function loadAutoCompleteParams() { const select2Autocompletes = document.querySelectorAll('select[data-autocomplete-url-value]') diff --git a/app/assets/javascripts/spree/backend/spree-select2.js b/app/assets/javascripts/spree/backend/spree-select2.js index 19f240f4a5..fb0e67283f 100644 --- a/app/assets/javascripts/spree/backend/spree-select2.js +++ b/app/assets/javascripts/spree/backend/spree-select2.js @@ -1,3 +1,10 @@ +// we need to delete select2 instances before document is saved to cache +// https://stackoverflow.com/questions/36497723/select2-with-ajax-gets-initialized-several-times-with-rails-turbolinks-events +document.addEventListener("turbo:before-cache", function() { + $('select.select2').select2('destroy') + $('select.select2-clear').select2('destroy') +}) + document.addEventListener("spree:load", function() { // Initiate a standard Select2 on any select element with the class .select2 // Remember to add a place holder in the HTML as needed. diff --git a/app/assets/stylesheets/spree/backend/shared/_base.scss b/app/assets/stylesheets/spree/backend/shared/_base.scss index 2c720af18e..6abd0a3942 100644 --- a/app/assets/stylesheets/spree/backend/shared/_base.scss +++ b/app/assets/stylesheets/spree/backend/shared/_base.scss @@ -44,8 +44,6 @@ div.admin-product-image-container { img { max-width: 100%; height: auto; - align-self: center; - transform: scale(1.6); } svg { diff --git a/app/controllers/spree/admin/return_index_controller.rb b/app/controllers/spree/admin/return_index_controller.rb index 12f5f83281..fcb1d78431 100644 --- a/app/controllers/spree/admin/return_index_controller.rb +++ b/app/controllers/spree/admin/return_index_controller.rb @@ -2,7 +2,7 @@ module Spree module Admin class ReturnIndexController < BaseController def return_authorizations - collection(Spree::ReturnAuthorization) + collection(Spree::ReturnAuthorization.for_store(current_store)) respond_with(@collection) end @@ -18,9 +18,8 @@ def collection(resource) params[:q] ||= {} - @collection = resource.all # @search needs to be defined as this is passed to search_form_for - @search = @collection.ransack(params[:q]) + @search = resource.ransack(params[:q]) per_page = params[:per_page] || Spree::Backend::Config[:admin_customer_returns_per_page] @collection = @search.result.order(created_at: :desc).page(params[:page]).per(per_page) end diff --git a/app/views/spree/admin/images/index.html.erb b/app/views/spree/admin/images/index.html.erb index e98db044eb..40e5c2810d 100644 --- a/app/views/spree/admin/images/index.html.erb +++ b/app/views/spree/admin/images/index.html.erb @@ -42,7 +42,7 @@