mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Fix product index
The param product_index wasn't present, so it was always choosing 1. The products on page are indexed 0-14, so of course it would always conflict. It would be simpler if we just used product IDs as the index, I think I did earlier but don't remember why not. Anyway, using a negative number seems to work. If there's an error, there will only be one at a time.
This commit is contained in:
@@ -70,19 +70,20 @@ module Admin
|
||||
|
||||
def clone
|
||||
@product = Spree::Product.find(params[:id])
|
||||
@product_index = params[:product_index].to_i + 1
|
||||
status = :ok
|
||||
|
||||
begin
|
||||
@cloned_product = @product.duplicate
|
||||
flash.now[:success] = t('.success')
|
||||
|
||||
@product_index = "-#{@cloned_product.id}"
|
||||
@producer_options = producers
|
||||
@category_options = categories
|
||||
@tax_category_options = tax_category_options
|
||||
rescue StandardError => _e
|
||||
flash.now[:error] = t('.error')
|
||||
status = :internal_server_error
|
||||
@product_index = "-1" # Create a unique enough index
|
||||
end
|
||||
|
||||
respond_with do |format|
|
||||
|
||||
Reference in New Issue
Block a user