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
Small improvements to product form option values handling (#12945)
Damian Legawieca5b711016591
diff --git a/admin/app/controllers/spree/admin/option_values_controller.rb b/admin/app/controllers/spree/admin/option_values_controller.rbindex c1f237ca9e..5efa72d60e 100644--- a/admin/app/controllers/spree/admin/option_values_controller.rb+++ b/admin/app/controllers/spree/admin/option_values_controller.rb@@ -20,6 +20,15 @@ module Spreedef permitted_resource_paramsparams.require(:option_value).permit(permitted_option_value_attributes)end++ # for select_options action, we only require read permission+ def authorize_admin+ if action == :select_options+ authorize! :read, Spree::OptionValue+ else+ super+ end+ endendendenddiff --git a/admin/app/views/spree/admin/products/form/_variants.html.erb b/admin/app/views/spree/admin/products/form/_variants.html.erbindex d96d58f38c..884c475f44 100644--- a/admin/app/views/spree/admin/products/form/_variants.html.erb+++ b/admin/app/views/spree/admin/products/form/_variants.html.erb@@ -56,7 +56,7 @@<label class="label" for="new_option_name"><%= Spree.t(:option_name) %></label><%= tom_select_tag :new_option_name,multiple: false,- create: true,+ create: can?(:create, Spree::OptionType),preloaded_options: option_types_for_select,include_blank: true,select_data: {diff --git a/core/app/services/spree/products/prepare_nested_attributes.rb b/core/app/services/spree/products/prepare_nested_attributes.rbindex df788942ea..dc8cd7b08a 100644--- a/core/app/services/spree/products/prepare_nested_attributes.rb+++ b/core/app/services/spree/products/prepare_nested_attributes.rb@@ -140,8 +140,8 @@ module Spreeoption_value_identificator = if opt[:option_value_name].present?opt[:option_value_name]else- opt[:option_value_presentation].parameterize- end.strip+ opt[:option_value_presentation]+ end.parameterize.stripoption_value = option_type.option_values.where(name: option_value_identificator).first_or_initialize do |o|o.presentation = opt[:option_value_presentation]