corretto bug GruppoMacro la lista veniva salvata ma anche aggiornata in memoria con solo gli ID... in questo caso TABLES_NON_AGGIORNARE_IN_MEMORIA_PERCHE_DIVERSA_STRUTTURA gli dice che alcune tabelle non devono essere aggiornate in memoria.
This commit is contained in:
@@ -32,9 +32,6 @@ import { CSearchProduct } from '@src/components/CSearchProduct';
|
||||
import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard';
|
||||
import { CSelectUserActive } from '@src/components/CSelectUserActive';
|
||||
|
||||
import html2pdf from 'html2pdf.js';
|
||||
import { saveAs } from 'file-saver';
|
||||
|
||||
import type {
|
||||
IOptCatalogo,
|
||||
IDimensioni,
|
||||
@@ -1206,7 +1203,7 @@ export default defineComponent({
|
||||
});
|
||||
}
|
||||
|
||||
function arraysEqual(arr1, arr2) {
|
||||
function arraysEqual(arr1: any, arr2: any) {
|
||||
return (
|
||||
Array.isArray(arr1) &&
|
||||
Array.isArray(arr2) &&
|
||||
@@ -1300,10 +1297,6 @@ export default defineComponent({
|
||||
sort_dir: number
|
||||
): IProduct[] {
|
||||
if (sort_field) {
|
||||
// console.log('--- Primi 10 elementi INIZIALI:');
|
||||
/*arrprod.slice(0, 15).forEach((product, index) => {
|
||||
console.log(`${index + 1}. ${product.productInfo?.name} (${product.productInfo?.date_pub})`);
|
||||
});*/
|
||||
|
||||
// Crea una copia dell'array per non modificare l'originale
|
||||
const sortedArr = [...arrprod].sort((a: IProduct, b: IProduct) => {
|
||||
@@ -1367,7 +1360,7 @@ export default defineComponent({
|
||||
return { end: true };
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return { rec: null, indprod };
|
||||
return { indprod };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1384,17 +1377,17 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function generatearrProdToViewSorted(
|
||||
async function generatearrProdToViewSorted(
|
||||
usaprodottiSalvati?: boolean,
|
||||
salva?: boolean,
|
||||
salvasudb?: boolean
|
||||
) {
|
||||
/*console.log(
|
||||
console.log(
|
||||
'generatearrProdToViewSorted... usaprodottiSalvati=',
|
||||
usaprodottiSalvati,
|
||||
' salva=',
|
||||
salva
|
||||
);*/
|
||||
);
|
||||
|
||||
try {
|
||||
// Svuota
|
||||
@@ -1533,7 +1526,7 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
if (salvasudb) {
|
||||
salvaListaProdotti(false);
|
||||
await salvaListaProdotti(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1544,7 +1537,7 @@ export default defineComponent({
|
||||
// console.log('Fine...')
|
||||
}
|
||||
|
||||
function salvaListaProdotti(ricarica: boolean) {
|
||||
async function salvaListaProdotti(ricarica: boolean) {
|
||||
// Estrai solo gli ID dei prodotti filtrati
|
||||
const myarr = [...myCatalog.value.lista_prodotti];
|
||||
const productIds = myarr.map((product) => product._id);
|
||||
@@ -1556,7 +1549,7 @@ export default defineComponent({
|
||||
};
|
||||
|
||||
// Salva gli ID dei prodotti nel catalogo
|
||||
tools.saveFieldToServer(
|
||||
await tools.saveFieldToServer(
|
||||
$q,
|
||||
'catalogs',
|
||||
myCatalog.value._id,
|
||||
@@ -1566,7 +1559,7 @@ export default defineComponent({
|
||||
);
|
||||
|
||||
if (ricarica) {
|
||||
generatearrProdToViewSorted(true, false);
|
||||
await generatearrProdToViewSorted(true, false);
|
||||
}
|
||||
|
||||
// lista_Aggiornata();
|
||||
@@ -2376,7 +2369,8 @@ export default defineComponent({
|
||||
router.push(path);
|
||||
}
|
||||
|
||||
function updateProducts(arr: any, aggiorna?: boolean) {
|
||||
async function updateProducts(arr: any, aggiorna?: boolean) {
|
||||
console.log('UpdateProducts', arr.length)
|
||||
if (myCatalog.value && myCatalog.value?.lista_prodotti) {
|
||||
if (
|
||||
myCatalog.value.lista_prodotti?.length !== arr.length ||
|
||||
@@ -2387,13 +2381,16 @@ export default defineComponent({
|
||||
) {
|
||||
myCatalog.value.lista_prodotti = [...arr];
|
||||
|
||||
if (!showListaFiltrata.value && !tools.isUtente()) salvaListaProdotti(true);
|
||||
else generatearrProdToViewSorted(true, false);
|
||||
if (!showListaFiltrata.value && !tools.isUtente()) {
|
||||
await salvaListaProdotti(true);
|
||||
} else {
|
||||
await generatearrProdToViewSorted(true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addProductToList(element: IProduct, where: string) {
|
||||
async function addProductToList(element: IProduct, where: string) {
|
||||
console.log('addProductToList', element)
|
||||
|
||||
if (element) {
|
||||
@@ -2407,7 +2404,7 @@ export default defineComponent({
|
||||
if (where === shared_consts.WHERE_INSERT.ONTOP) arr.unshift(element);
|
||||
else if (where === shared_consts.WHERE_INSERT.ONBOTTOM) arr.push(element);
|
||||
|
||||
updateProducts(arr, true);
|
||||
await updateProducts(arr, true);
|
||||
|
||||
addnewProd.value = false;
|
||||
}
|
||||
@@ -2697,9 +2694,9 @@ export default defineComponent({
|
||||
});
|
||||
}
|
||||
|
||||
function convertiProps(obj?: Record<string, string | undefined>, props: string[]) {
|
||||
function convertiProps(obj: Record<string, string | undefined>, myprops: string[]) {
|
||||
if (!obj) return;
|
||||
props.forEach((prop) => {
|
||||
myprops.forEach((prop) => {
|
||||
if (obj[prop] !== undefined) obj[prop] = converti(obj[prop]!);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,9 +29,6 @@ import { CSearchProduct } from '@src/components/CSearchProduct';
|
||||
import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard';
|
||||
import { CSelectUserActive } from '@src/components/CSelectUserActive';
|
||||
|
||||
import html2pdf from 'html2pdf.js';
|
||||
import { saveAs } from 'file-saver';
|
||||
|
||||
import type {
|
||||
IOptCatalogo,
|
||||
IDimensioni,
|
||||
|
||||
Reference in New Issue
Block a user