mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-21 05:09:15 +00:00
11987: refactored code
This commit is contained in:
@@ -70,21 +70,21 @@ module Admin
|
||||
|
||||
def clone
|
||||
@product = Spree::Product.find(params[:id])
|
||||
@cloned_product = @product.duplicate
|
||||
@product_index = params[:product_index].to_i + 1
|
||||
|
||||
status = :ok
|
||||
if @cloned_product.save
|
||||
|
||||
begin
|
||||
@cloned_product = @product.duplicate
|
||||
flash.now[:success] = t('.success')
|
||||
else
|
||||
|
||||
@producer_options = producers
|
||||
@category_options = categories
|
||||
@tax_category_options = tax_category_options
|
||||
rescue StandardError => _e
|
||||
flash.now[:error] = t('.error')
|
||||
status = :internal_server_error
|
||||
end
|
||||
|
||||
@producer_options = producers
|
||||
@category_options = categories
|
||||
@tax_category_options = tax_category_options
|
||||
|
||||
respond_with do |format|
|
||||
format.turbo_stream { render :clone, status: }
|
||||
end
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
- unless flash[:error]
|
||||
- product_body = nil
|
||||
- form_with url: bulk_update_admin_products_path, method: :post, id: "products-form",
|
||||
builder: BulkFormBuilder,
|
||||
html: { data: { 'turbo-frame': "_self",
|
||||
controller: "bulk-form",
|
||||
'bulk-form-disable-selector-value': "#sort,#filters",
|
||||
'bulk-form-error-value': defined?(@error_counts),
|
||||
} } do |form|
|
||||
- product_body = render partial: 'product_variant_row', locals: { form:, product: @cloned_product, product_index: @product_index, producer_options: @producer_options, category_options: @category_options, tax_category_options: @tax_category_options, should_slide_in: true }, formats: :html
|
||||
- form_with do |form|
|
||||
- product_body = render(partial: 'product_variant_row',
|
||||
locals: { form:,
|
||||
product: @cloned_product,
|
||||
product_index: @product_index,
|
||||
producer_options: @producer_options,
|
||||
category_options: @category_options,
|
||||
tax_category_options: @tax_category_options,
|
||||
should_slide_in: true },
|
||||
formats: :html)
|
||||
= turbo_stream.before dom_id(@product) do
|
||||
= product_body
|
||||
|
||||
|
||||
Reference in New Issue
Block a user