mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add default shipping category during object creation; revert forms
This commit is contained in:
@@ -30,6 +30,11 @@ Spree::Admin::ProductsController.class_eval do
|
||||
@show_latest_import = params[:latest_import] || false
|
||||
end
|
||||
|
||||
def new
|
||||
@object.shipping_category = DefaultShippingCategory.find_or_create
|
||||
super
|
||||
end
|
||||
|
||||
def create
|
||||
delete_stock_params_and_set_after do
|
||||
super
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
= f.field_container :shipping_categories do
|
||||
= f.label :shipping_category_id, t(:shipping_category)
|
||||
= f.collection_select(:shipping_category_id, Spree::ShippingCategory.all, :id, :name, {:include_blank => false, :selected => DefaultShippingCategory.find_or_create.id}, {:class => 'select2 fullwidth'})
|
||||
= f.collection_select(:shipping_category_id, Spree::ShippingCategory.all, :id, :name, {:include_blank => false}, {:class => 'select2 fullwidth'})
|
||||
= f.error_message_on :shipping_category_id
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
= f.field_container :categories do
|
||||
- Spree::ShippingCategory.all.each do |category|
|
||||
= label_tag do
|
||||
= check_box_tag('shipping_method[shipping_categories][]', category.id, category == DefaultShippingCategory.find_or_create)
|
||||
= check_box_tag('shipping_method[shipping_categories][]', category.id, @shipping_method.shipping_categories.include?(category))
|
||||
= category.name
|
||||
%br/
|
||||
= error_message_on :shipping_method, :shipping_category_id
|
||||
|
||||
Reference in New Issue
Block a user