mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-04 22:16:08 +00:00
Show edit form for new images
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
module Admin
|
||||
class ProductsV3Controller < Spree::Admin::BaseController
|
||||
helper ProductsHelper
|
||||
|
||||
before_action :init_filters_params
|
||||
before_action :init_pagination_params
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@ module Spree
|
||||
def new
|
||||
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
|
||||
|
||||
render layout: !request.xhr?
|
||||
respond_with do |format|
|
||||
format.turbo_stream { render :edit }
|
||||
format.all { render layout: !request.xhr? }
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
13
app/helpers/admin/products_helper.rb
Normal file
13
app/helpers/admin/products_helper.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
module ProductsHelper
|
||||
def product_image_form_path(product)
|
||||
if product.image.present?
|
||||
edit_admin_product_image_path(product.id, product.image.id)
|
||||
else
|
||||
new_admin_product_image_path(product.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1,7 @@
|
||||
%td.with-image{ id: "image-#{product.id}" }
|
||||
- if product.image.present? # todo: handle blank img
|
||||
%a.image-field{ href: edit_admin_product_image_path(product.id, product.image.id), 'data-turbo-stream': true }
|
||||
= image_tag product.image&.url(:mini) || Spree::Image.default_image_url(:mini), width: 40, height: 40
|
||||
.button.secondary.mini= t('admin.products_page.image.edit')
|
||||
%a.image-field{ href: product_image_form_path(product), 'data-turbo-stream': true }
|
||||
= image_tag product.image&.url(:mini) || Spree::Image.default_image_url(:mini), width: 40, height: 40
|
||||
.button.secondary.mini= t('admin.products_page.image.edit')
|
||||
%td.field.align-left.header.naked_inputs
|
||||
= f.hidden_field :id
|
||||
= f.text_field :name, 'aria-label': t('admin.products_page.columns.name')
|
||||
|
||||
Reference in New Issue
Block a user