- piuchebuono: possiblità di modificare l'immagine dalla scheda direttamente

- migliorata di poco la grafica dell'immagine.
This commit is contained in:
Surya Paolo
2024-10-03 03:55:05 +02:00
parent f9e0175f9b
commit d438867e3a
7 changed files with 85 additions and 15 deletions

View File

@@ -230,7 +230,7 @@ module.exports.getProductByCode = function (idapp, code) {
module.exports.replaceProductImgToImageFile = async function () {
const ProductInfo = this;
let abilitaserver = false;
let abilitaserver = true;
if (abilitaserver) {
// const result = await ProductInfo.updateMany({ "img": { $exists: true } }, { $rename: { 'img': 'imagefile' } });
@@ -240,9 +240,9 @@ module.exports.replaceProductImgToImageFile = async function () {
// Aggiorna ciascun documento
for (let doc of documents) {
if (doc.img && doc.img.startsWith('/upload/products/')) {
if (doc.img && doc.img.startsWith('upload/products/')) {
// Rimuovi il prefisso '/upload/products' dal campo `img`
doc.imagefile = doc.img.replace(/^\/upload\/products\//, '');
doc.imagefile = doc.img.replace(/^\upload\/products\//, '');
doc.img = undefined; // Può anche rimuovere il campo img corrente se desiderato
await doc.save(); // Salva il documento aggiornato
}