muiltiple images in carousel
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use crate::models::_entities::{categories, product_variants, products};
|
||||
use crate::models::_entities::{categories, product_images, product_variants, products};
|
||||
use crate::shared::money::format_price;
|
||||
use crate::shared::pricing::PricedProduct;
|
||||
|
||||
@@ -61,9 +61,9 @@ pub fn variant_option(variant: &product_variants::Model, priced: &PricedProduct)
|
||||
}
|
||||
|
||||
/// Shape used to pre-fill the admin product form (exposes `category_id` rather
|
||||
/// than a resolved name, and the current primary image). Variants are supplied
|
||||
/// separately by the controller.
|
||||
pub fn product_form(product: &products::Model, image: Option<String>) -> Value {
|
||||
/// than a resolved name, and the current images in display order — first is the
|
||||
/// main one). Variants are supplied separately by the controller.
|
||||
pub fn product_form(product: &products::Model, images: &[product_images::Model]) -> Value {
|
||||
json!({
|
||||
"id": product.id,
|
||||
"name": product.name,
|
||||
@@ -72,7 +72,10 @@ pub fn product_form(product: &products::Model, image: Option<String>) -> Value {
|
||||
"currency": product.currency,
|
||||
"published": product.published,
|
||||
"category_id": product.category_id,
|
||||
"image": image,
|
||||
"images": images
|
||||
.iter()
|
||||
.map(|im| json!({ "id": im.id, "image_id": im.image_id }))
|
||||
.collect::<Vec<_>>(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user