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 @@
- <%= link_to image_tag(main_app.url_for(image.url(:product))), main_app.rails_blob_url(image.attachment) %> + <%= link_to image_tag(main_app.url_for(image.url(:mini))), main_app.rails_blob_url(image.attachment) %>
<% if has_variants %> diff --git a/app/views/spree/admin/products/_form.html.erb b/app/views/spree/admin/products/_form.html.erb index 360d08bee2..e008970316 100644 --- a/app/views/spree/admin/products/_form.html.erb +++ b/app/views/spree/admin/products/_form.html.erb @@ -231,7 +231,6 @@ <%= f.select :option_type_ids, options_from_collection_for_select(@product.option_types, :id, :name, @product.option_type_ids), { include_hidden: true }, multiple: true, - class: 'select2-hidden-accessible', data: { autocomplete_url_value: 'option_types_api_v2', autocomplete_return_attr_value: 'name', autocomplete_multiple_value: true } %> diff --git a/app/views/spree/admin/products/index.html.erb b/app/views/spree/admin/products/index.html.erb index d67426da4b..87179d73eb 100644 --- a/app/views/spree/admin/products/index.html.erb +++ b/app/views/spree/admin/products/index.html.erb @@ -10,7 +10,6 @@
<%= search_form_for [:admin, @search] do |f| %> - <%- locals = {f: f} %>
diff --git a/app/views/spree/admin/stores/_form.html.erb b/app/views/spree/admin/stores/_form.html.erb index 3a24354172..4e21c02c2d 100644 --- a/app/views/spree/admin/stores/_form.html.erb +++ b/app/views/spree/admin/stores/_form.html.erb @@ -152,7 +152,7 @@ <% end %> <%= f.field_container :checkout_zone_id do %> <%= f.label :checkout_zone_id, Spree.t(:zone) %> - <%= f.select :checkout_zone_id, options_for_select(@zones, selected_checkout_zone(@store)&.id), { include_blank: Spree.t(:no_limits_zone) }, { class: 'select2' } %> + <%= f.select :checkout_zone_id, options_for_select(@zones), { include_blank: Spree.t(:no_limits_zone) }, { class: 'select2' } %> <%= raw(Spree.t('store_form.checkout_zone_help')) %> diff --git a/lib/spree/backend/version.rb b/lib/spree/backend/version.rb index db1437df2a..c855c204c9 100644 --- a/lib/spree/backend/version.rb +++ b/lib/spree/backend/version.rb @@ -1,6 +1,6 @@ module Spree module Backend - VERSION = '4.4.0.rc1'.freeze + VERSION = '4.4.0'.freeze def self.version VERSION diff --git a/spec/controllers/spree/admin/return_index_controller_spec.rb b/spec/controllers/spree/admin/return_index_controller_spec.rb index 28cb2b7aa2..f75887f93e 100644 --- a/spec/controllers/spree/admin/return_index_controller_spec.rb +++ b/spec/controllers/spree/admin/return_index_controller_spec.rb @@ -11,12 +11,18 @@ module Admin end let(:return_authorization) { create(:return_authorization) } + let(:order_other_store) { create(:shipped_order, store: create(:store)) } + let(:return_authorization_other_store) { create(:return_authorization, order: order_other_store) } before { subject } it 'loads return authorizations' do expect(assigns(:collection)).to include(return_authorization) end + + it 'does not include other store return authorization' do + expect(assigns(:collection)).not_to include(return_authorization_other_store) + end end describe '#customer_returns' do diff --git a/spec/features/admin/configuration/stores_spec.rb b/spec/features/admin/configuration/stores_spec.rb index f7e4218c81..704178661c 100644 --- a/spec/features/admin/configuration/stores_spec.rb +++ b/spec/features/admin/configuration/stores_spec.rb @@ -48,6 +48,7 @@ expect(page).to have_current_path(spree.new_admin_store_path) expect(page).to have_selector(:id, 'select2-store_default_currency-container', text: 'United States Dollar (USD)') + expect(page).to have_field('store_checkout_zone_id', text: 'No Limits') end it 'saving store' do