Cataloghi...

This commit is contained in:
Surya Paolo
2025-02-05 12:13:27 +01:00
parent 41d5f562ec
commit 2f92dfe5b0
13 changed files with 498 additions and 458 deletions

View File

@@ -60,7 +60,7 @@ const catalogo = new Schema(
excludeproductTypes: [{ type: Number }],
editore: [{ type: String }],
argomenti: [{ type: String }],
idCollana: { type: Number },
idCollane: [{ type: Number }],
sort_field: { type: String },
sort_dir: { type: Number },
pdf: { type: Boolean },
@@ -361,7 +361,21 @@ MyElemSchema.statics.findAllIdApp = async function (idapp) {
const myfind = { idapp };
const arrrec = await MyElem.find(myfind).lean().sort({ order: 1 });
const aggiorna = false;
let arrrec = null;
if (aggiorna) {
arrrec = await MyElem.find(myfind).sort({ order: 1 });
for (const elem of arrrec) {
if (elem.heightimg === 'NaNpx') {
elem.heightimg = '';
await elem.save();
}
}
} else {
arrrec = await MyElem.find(myfind).lean().sort({ order: 1 });
}
return arrrec;
};
@@ -374,13 +388,13 @@ MyElemSchema.statics.findallSchedeTemplate = async function (idapp) {
const ris = await MyElem.find({ idapp }).lean();
const schedeTemplate = ris.flatMap(elem =>
elem.catalogo && elem.catalogo.arrSchede ?
elem.catalogo && elem.catalogo.arrSchede ?
elem.catalogo.arrSchede
.filter(scheda => scheda.scheda?.isTemplate)
.map(scheda => ({
...scheda, // mantieni i dati originali della scheda
idPageOrig: elem.idPage // aggiungi l'idPage
}))
}))
: []
);