Add product detail to the modal

This commit is contained in:
Gaetan Craig-Riou
2024-08-28 11:51:09 +10:00
parent 27dd5def57
commit f24a4edc68
2 changed files with 38 additions and 5 deletions

View File

@@ -3,11 +3,11 @@
module Admin
class ProductPreviewController < Spree::Admin::BaseController
def show
@id = params[:id]
# TODO load product data based on param
@product = Spree::Product.find(params[:id])
respond_with do |format|
format.turbo_stream {
render "admin/products_v3/product_preview", status: :ok, locals: { id: @id }
render "admin/products_v3/product_preview", status: :ok
}
end
end

View File

@@ -1,5 +1,38 @@
= turbo_stream.replace "product-preview" do
#product-preview
This is where the product preview will be, id:
= @id
.row
.columns.small-12.medium-6.large-6.product-header
%h3
= @product.name
%span
%em
= t("products_from")
%span
= @product.variants.first.supplier.name
%br-
.filter-shopfront.property-selectors.inline-block
%ul
- @product.properties_including_inherited.each do |property|
%li
%span
- if property[:value].present?
= render partial: "admin/shared/tooltip", locals: { tooltip_text: property[:value], link_text: property[:name], placement: "bottom" }
- else
%a
= property[:name]
- if @product.description
.product-description
- # TODO description not wrapped properly
%p.text-small{ 'data-controller': "add-blank-to-link" }
- # description is sanitized in Spree::Product#description method
= @product.description.html_safe
.columns.small-12.medium-6.large-6.product-img
- if @product.image
%img{ src: @product.image.url(:large) }
-else
%img.placeholder{ src: Spree::Image.default_image_url(:large) }