- piuchebuono: possiblità di modificare l'immagine dalla scheda direttamente
- migliorata di poco la grafica dell'immagine.
This commit is contained in:
@@ -63,9 +63,9 @@ async function downloadImgIfMissing(productInfo) {
|
||||
const img = 'upload/products/' + productInfo.image_link.split('/').pop();
|
||||
const savePath = path.resolve(__dirname, img); // Sostituisci con il percorso dove salvare l'immagine
|
||||
|
||||
if (!productInfo.img || !fs.existsSync(savePath)) {
|
||||
if (!productInfo.imagefile || !fs.existsSync(savePath)) {
|
||||
// Download image from the URL productInfo.image_link
|
||||
productInfo.img = img;
|
||||
productInfo.imagefile = img;
|
||||
|
||||
const downloader = new ImageDownloader();
|
||||
|
||||
@@ -131,13 +131,13 @@ async function completaSettaggioProduct_AndProductInfo(arrcampi_productInfo, arr
|
||||
}
|
||||
|
||||
if (!rec.hasOwnProperty('img') && product.code) {
|
||||
productInfo.img = 'upload/products/' + product.code + '.jpg';
|
||||
productInfo.imagefile = 'upload/products/' + product.code + '.jpg';
|
||||
} else {
|
||||
if (rec.hasOwnProperty('img')) {
|
||||
if (rec['img']) {
|
||||
productInfo.img = 'upload/products/' + rec['img'];
|
||||
productInfo.imagefile = 'upload/products/' + rec['img'];
|
||||
} else {
|
||||
productInfo.img = '';
|
||||
productInfo.imagefile = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1042,6 +1042,10 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
product.active = true;
|
||||
}
|
||||
|
||||
if (productInfo.productTypes.length === 1 && productInfo.productTypes[0] === undefined) {
|
||||
productInfo.productTypes = [shared_consts.PRODUCTTYPE.PRODUCT];
|
||||
}
|
||||
|
||||
let esisteindb = await ProductInfo.findOne({ code: productInfo.code }).lean();
|
||||
|
||||
// Update ProductInfo
|
||||
|
||||
@@ -957,7 +957,7 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
precRec = await mytable.findById(id);
|
||||
}
|
||||
|
||||
return await mytable.findByIdAndUpdate(id, { $set: fieldsvalue }).
|
||||
return await mytable.findByIdAndUpdate(id, { $set: fieldsvalue }, { new: true }).
|
||||
then(async (rec) => {
|
||||
// tools.mylogshow(' REC TO MODIFY: ', rec);
|
||||
if (!rec) {
|
||||
|
||||
@@ -1650,6 +1650,9 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
} else if (mydata.dbop === 'correggiProductTypes') {
|
||||
|
||||
await ProductInfo.correggiProductTypes();
|
||||
} else if (mydata.dbop === 'replaceProductImgToImageFile') {
|
||||
|
||||
await ProductInfo.replaceProductImgToImageFile();
|
||||
|
||||
} else if (mydata.dbop === 'correggiCircuitiANull') {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user