Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed thumbnail images #188

Closed
wants to merge 10 commits into from
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/spree/backend/address_states.es6
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 6 additions & 0 deletions app/assets/javascripts/spree/backend/global/flatpickr.es6
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})

Original file line number Diff line number Diff line change
Expand Up @@ -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]')
Expand Down
7 changes: 7 additions & 0 deletions app/assets/javascripts/spree/backend/spree-select2.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 0 additions & 2 deletions app/assets/stylesheets/spree/backend/shared/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ div.admin-product-image-container {
img {
max-width: 100%;
height: auto;
align-self: center;
transform: scale(1.6);
}

svg {
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/spree/admin/return_index_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/spree/admin/images/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</td>
<td class="image">
<div class="admin-product-image-container small-img">
<%= 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) %>
</div>
</td>
<% if has_variants %>
Expand Down
1 change: 0 additions & 1 deletion app/views/spree/admin/products/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 } %>
Expand Down
1 change: 0 additions & 1 deletion app/views/spree/admin/products/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<div data-hook="admin_products_sidebar">

<%= search_form_for [:admin, @search] do |f| %>
<%- locals = {f: f} %>
<div data-hook="admin_products_index_search" class="row">
<div class="col-12 col-lg-6">
<div class="form-group">
Expand Down
2 changes: 1 addition & 1 deletion app/views/spree/admin/stores/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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' } %>
<small class="form-text text-muted">
<%= raw(Spree.t('store_form.checkout_zone_help')) %>
</small>
Expand Down
2 changes: 1 addition & 1 deletion lib/spree/backend/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Spree
module Backend
VERSION = '4.4.0.rc1'.freeze
VERSION = '4.4.0'.freeze

def self.version
VERSION
Expand Down
6 changes: 6 additions & 0 deletions spec/controllers/spree/admin/return_index_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/features/admin/configuration/stores_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down