- miglioramenti ricerca titoli e modifica del trafiletto

- miglior visualizzazione delle liste
This commit is contained in:
Surya Paolo
2025-04-30 13:27:54 +02:00
parent 3d4f8b0d04
commit e40fbd550b
12 changed files with 277 additions and 134 deletions

View File

@@ -133,7 +133,6 @@ const productSchema = new Schema({
},
maxBookableSinglePersQty: { // quantità massima Pre-ordinabile (singolarmente)
type: Number,
default: 0,
},
stockQty: { // in magazzino
type: Number,
@@ -141,58 +140,45 @@ const productSchema = new Schema({
},
stockBloccatiQty: { // Prenotati Bloccati
type: Number,
default: 0,
},
bookedQtyOrdered: { // Quantità Prenotate ordinate (in Lavorazione)
type: Number,
default: 0,
},
bookedQtyConfirmed: { // Quantità Prenotate Confermate Totali
type: Number,
default: 0,
},
// GAS:
qtyToReachForGas: { // Quantità minima da raggiungere per fare l'ordine GAS
type: Number,
default: 0,
},
maxbookableGASQty: { // Quantità massima (ancora disponibile) Ordine GAS prenotabile (Complessivamente tra tutti gli ordini)
type: Number,
default: 0,
},
bookedGASQtyOrdered: { // Quantità Ordine GAS Prenotate Totali
type: Number,
default: 0,
},
bookedGASQtyConfirmed: { // Quantità Ordine GAS Confermate Totali
type: Number,
default: 0,
},
bookableGASBloccatiQty: { // Quantità Prenotate Bloccate GAS
type: Number,
default: 0,
},
quantityLow: { //Soglia disponibilità bassa
type: Number,
default: 0,
},
visibilityProductOutOfStock: { // Visibilità prodotto "esaurito"
type: Boolean,
default: false,
},
canBeShipped: { // è spedibile
type: Boolean,
default: false,
},
canBeBuyOnline: { // è acquistabile online
type: Boolean,
default: false,
},
stars: {
type: Number,
default: 0,
},
dateAvailableFrom: {
type: Date
@@ -279,48 +265,24 @@ module.exports.executeQueryPickup = async function (idapp, params) {
// 🔹 Pattern per productInfo.name: tutte le parole devono essere presenti
const patternAllWords = words.map(w => `(?=.*\\b${escapeRegex(w)})`).join('') + '.*';
// 🔹 Condizioni per autori
let authorConditions = [];
// Se ci sono esattamente 2 parole (es. "antonio graziano")
if (words.length === 2) {
const [w1, w2] = words.map(escapeRegex);
authorConditions = [
{
'productInfo.authors': {
$elemMatch: {
name: { $regex: `^${w1}`, $options: 'i' },
surname: { $regex: `^${w2}`, $options: 'i' }
}
}
},
{
'productInfo.authors': {
$elemMatch: {
name: { $regex: `^${w2}`, $options: 'i' },
surname: { $regex: `^${w1}`, $options: 'i' }
}
}
}
];
}
// Se c'è solo una parola (es. "antonio")
if (words.length === 1) {
const word = escapeRegex(words[0]);
authorConditions = [
{
if (words.length > 0) {
authorConditions = words.map((word) => {
const regex = new RegExp(escapeRegex(word), 'i');
return {
'productInfo.authors': {
$elemMatch: {
$or: [
{ name: { $regex: `^${word}`, $options: 'i' } },
{ surname: { $regex: `^${word}`, $options: 'i' } }
{ name: regex },
{ surname: regex }
]
}
}
}
];
};
});
authorConditions = [{ $and: authorConditions }];
}
// 🔹 Filtro finale
@@ -780,6 +742,7 @@ module.exports.findAllIdApp = async function (idapp, code, id, all) {
} catch (e) {
console.error('E', e);
return [];
}