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
Add option to method.
Matthew Kennedyf3834195e6b7
diff --git a/backend/app/helpers/spree/admin/base_helper.rb b/backend/app/helpers/spree/admin/base_helper.rbindex 35c2082afd..eb86460ca4 100644--- a/backend/app/helpers/spree/admin/base_helper.rb+++ b/backend/app/helpers/spree/admin/base_helper.rb@@ -33,15 +33,23 @@ module Spreedef spree_humanize_dropdown_values(object, options = {})formatted_options = []+const = options[:const] || nil- attribute_name = options[:attr] || nil+ text = options[:text] || nil+ value = options[:value] || 'id'+ paramterize_value = options[:paramterize_value] || falseif object.is_a? String- object.constantize.const_get(const).- map { |type| formatted_options << [spree_humanize_type(type), type] }- elsif attribute_name.present? && const.nil?- object.map { |obj| formatted_options << [obj.send(attribute_name), obj.id] }- elsif attribute_name.nil? && const.present?+ if paramterize_value+ object.constantize.const_get(const).+ map { |type| formatted_options << [spree_humanize_type(type), type.parameterize(separator: '_')] }+ else+ object.constantize.const_get(const).+ map { |type| formatted_options << [spree_humanize_type(type), type] }+ end+ elsif text.present? && const.nil?+ object.map { |obj| formatted_options << [obj.send(text), obj.send(value)] }+ elsif text.nil? && const.present?object.class.const_get(const).map { |type| formatted_options << [spree_humanize_type(type), type] }enddiff --git a/backend/app/views/spree/admin/menus/index.html.erb b/backend/app/views/spree/admin/menus/index.html.erbindex 8ff6cd9816..f3ef194efb 100644--- a/backend/app/views/spree/admin/menus/index.html.erb+++ b/backend/app/views/spree/admin/menus/index.html.erb@@ -20,7 +20,7 @@<div class="col-12 col-lg-6"><div class="form-group"><%= label_tag :q_location_eq, Spree.t(:location) %>- <%= f.select :location_eq, spree_humanize_dropdown_values('Spree::Menu', {const: 'MENU_LOCATIONS'}), { include_blank: true }, class: 'select2-clear js-filterable' %>+ <%= f.select :location_eq, spree_humanize_dropdown_values('Spree::Menu', {const: 'MENU_LOCATIONS', paramterize_value: true}), { include_blank: true }, class: 'select2-clear js-filterable' %></div></div></div>@@ -35,7 +35,7 @@<div class="col-12 col-lg-6"><div class="form-group"><%= label_tag :q_store_id_in, Spree.t(:store) %>- <%= f.select :store_id_in, spree_humanize_dropdown_values(@stores, {attr: 'unique_name'}), { include_blank: true }, class: 'select2-clear js-filterable' %>+ <%= f.select :store_id_in, spree_humanize_dropdown_values(@stores, {text: 'unique_name'}), { include_blank: true }, class: 'select2-clear js-filterable' %></div></div></div>