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
Fixes For Issues With Placeholders
Matthew Kennedyd2df8d6058ec
diff --git a/backend/app/assets/javascripts/spree/backend/spree-select2.js b/backend/app/assets/javascripts/spree/backend/spree-select2.jsindex f95c7558fb..b3212dec1d 100644--- a/backend/app/assets/javascripts/spree/backend/spree-select2.js+++ b/backend/app/assets/javascripts/spree/backend/spree-select2.js@@ -1,8 +1,22 @@document.addEventListener('DOMContentLoaded', function() {- // Inititate Select2 on any select element with the class .select2- $('select.select2').select2({- allowClear: true,- placeholder: Spree.translations.select_an_option+ // Inititate a standard Select2 on any select element with the class .select2+ // Remember to add a place holder in the HTML as needed.+ $('select.select2').select2()++ // Inititate a Select2 with the option to clear, on any select element with the class .select2-clear+ // Set: include_blank: true in your ERB.+ // A placeholder is auto added here as it is required to clear the Select2+ // If a custom placeholder is required, you will need to set up a custom instance.+ $('select.select2-clear').select2({+ placeholder: Spree.translations.select_an_option,+ allowClear: true+ })++ // Inititate a Select2 with the multiple set to true, on any select element with the class .select2-multiple+ // Set include_blank: false in your ERB.+ // Manually add a placeholder in the html or ERB as needed.+ $('select.select2-multiple').select2({+ multiple: true})})diff --git a/backend/app/views/spree/admin/payment_methods/_form.html.erb b/backend/app/views/spree/admin/payment_methods/_form.html.erbindex 6a5cfb2632..3aaf83c93b 100644--- a/backend/app/views/spree/admin/payment_methods/_form.html.erb+++ b/backend/app/views/spree/admin/payment_methods/_form.html.erb@@ -26,8 +26,10 @@<div data-hook="store" class="form-group"><%= label_tag :payment_method_store, Spree.t(:store) %>- <%= collection_select(:payment_method, :store_id, @stores, :id, :unique_name, { include_blank: true }, {id: 'store_id', class: 'select2'}) %>+ <%= collection_select(:payment_method, :store_id, @stores, :id, :unique_name, { include_blank: true }, {id: 'store_id', class: 'select2-clear'}) %>+ <small id="emailHelp" class="form-text text-muted"><%= Spree.t(:leave_blank_to_show_in_all_stores) %></small></div>+<div data-hook="display" class="form-group"><%= label_tag :payment_method_display_on, Spree.t(:display) %><%= select(:payment_method, :display_on, Spree::PaymentMethod::DISPLAY.collect { |display| [Spree.t(display), display.to_s] }, {}, {class: 'select2'}) %>diff --git a/backend/spec/features/admin/configuration/stores_spec.rb b/backend/spec/features/admin/configuration/stores_spec.rbindex 1a53ac9beb..3089eb4c0a 100644--- a/backend/spec/features/admin/configuration/stores_spec.rb+++ b/backend/spec/features/admin/configuration/stores_spec.rb@@ -51,7 +51,7 @@ describe 'Stores admin', type: :feature, js: true doclick_link 'New Store'expect(page).to have_current_path(spree.new_admin_store_path)- expect(page).to have_selector(:id, 'select2-store_checkout_zone_id-container', text: 'Select an option')+ expect(page).to have_selector(:id, 'select2-store_checkout_zone_id-container', text: 'No Limits')endenddiff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex 0c2d4e7424..c6d68277e1 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -1015,6 +1015,7 @@ en:lastname: Last Namelast_name_begins_with: Last Name Begins Withlearn_more: Learn More+ leave_blank_to_show_in_all_stores: Leave this option blank to show this payment method in all stores.lifetime_stats: Lifetime Statslimit_usage_to: Limit usage toline_item_adjustments: "Line item adjustments"