From 6b9ddc89866166812fc0249a573b9d5e5b6cfbfc Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Thu, 12 Jun 2025 23:49:18 +0200 Subject: [PATCH] - Creazione di un Nuovo Catalogo (e la sua relativa pagina), a partire da un modello ed un catalogo esistente. - Aggiunta dei bottoni sul Ccatalogocard --- src/server/models/myelem.js | 4 +- src/server/models/mypage.js | 1 + src/server/modules/Macro.js | 1 + src/server/router/catalogs_router.js | 21 +- src/server/router/index_router.js | 82 +-- src/server/tools/general.js | 31 +- src/server/tools/globalTables.js | 856 ++++++++++++++++----------- 7 files changed, 557 insertions(+), 439 deletions(-) diff --git a/src/server/models/myelem.js b/src/server/models/myelem.js index 744199c..903e334 100755 --- a/src/server/models/myelem.js +++ b/src/server/models/myelem.js @@ -99,9 +99,9 @@ const MyElemSchema = new Schema({ path: { type: String, }, - oldpath: { + /*oldpath: { type: String, - }, + },*/ idPage: { type: String }, type: { type: Number, diff --git a/src/server/models/mypage.js b/src/server/models/mypage.js index 8ae5cd8..34818ba 100755 --- a/src/server/models/mypage.js +++ b/src/server/models/mypage.js @@ -208,6 +208,7 @@ MyPageSchema.statics.findOnlyStruttRec = async function (idapp) { path: 1, active: 1, onlyif_logged: 1, + isTemplate: 1, only_residenti: 1, only_admin: 1, inmenu: 1, diff --git a/src/server/modules/Macro.js b/src/server/modules/Macro.js index 29145f2..24072f7 100644 --- a/src/server/modules/Macro.js +++ b/src/server/modules/Macro.js @@ -476,6 +476,7 @@ class Macro { for (const recproduct of recproducts) { await this.elaboraProdotto(recproduct, opt); + const sku = recproduct.IdArticolo; if (sku) { diff --git a/src/server/router/catalogs_router.js b/src/server/router/catalogs_router.js index 2524b4b..c22b484 100755 --- a/src/server/router/catalogs_router.js +++ b/src/server/router/catalogs_router.js @@ -15,7 +15,8 @@ const _ = require('lodash'); const { Catalog } = require('../models/catalog'); -//GET /catalogs +const globalTables = require('../tools/globalTables'); + router.post('/', auth_default, async function (req, res, next) { const idapp = req.body.idapp; const userId = req.body.userId; @@ -46,4 +47,22 @@ router.get('/id/:id', async function (req, res) { } }); + +router.post('/addnew', authenticate, async function (req, res, next) { + const idapp = req.body.idapp; + const data = req.body.newCatalog; + + try { + const newrecs = await globalTables.addNewCatalog(idapp, data); + if (newrecs) { + return res.send({ code: server_constants.RIS_CODE_OK, data: newrecs }); + } else { + return res.send({ code: server_constants.RIS_CODE_OK, data: null }); + } + } catch (e) { + console.error('Error fetching catalog by ID:', e); + return res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: e.message }); + } +}); + module.exports = router; diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js index 92ee5e8..dcac2cb 100755 --- a/src/server/router/index_router.js +++ b/src/server/router/index_router.js @@ -430,7 +430,7 @@ router.post('/settable', authenticate, async (req, res) => { } else { if ( (mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && - (mytablerec._id === undefined || mytablerec._id === '0'|| mytablerec._id === 0) + (mytablerec._id === undefined || mytablerec._id === '0' || mytablerec._id === 0) ) { mytablerec._id = new ObjectId(); mydata._id = new ObjectId(); @@ -891,69 +891,6 @@ router.post('/getpage', async (req, res) => { return found; }); -async function duplicatePage(pageId, newpath) { - try { - // Trova il record di Page da duplicare - const pageToDuplicate = await MyPage.findById(pageId); - if (!pageToDuplicate) { - console.error('Page not found.'); - return; - } - - // Crea una copia del record di Page - const newPage = new MyPage({ - ...pageToDuplicate.toObject(), // Converte il documento Moongose in oggetto - _id: new mongoose.Types.ObjectId(), // Genera un nuovo ID - // modifiche ai campi se necessario, per esempio: - path: newpath, - title: newpath, - inmenu: false, - active: true, - date_updated: new Date(), - }); - - // Salva il nuovo record di Page - await newPage.save(); - - // Trova tutti gli elementi associati a Page da duplicare - const elemsToDuplicate = await MyElem.find({ idPage: pageId }).lean(); - - // Duplica ogni elemento utilizzando il nuovo idPath - const duplicates = elemsToDuplicate.map((elem) => { - const catalogo = elem.catalogo; - - if (catalogo) { - for (const recscheda of catalogo.arrSchede) { - if (recscheda.scheda?.isTemplate) { - // Se è un template allora devo mettergli un altro ID ! - recscheda.scheda._id = new mongoose.Types.ObjectId(); - // recscheda.scheda.name = getNewFreeNameTemplate(recscheda.scheda?.name) - } - } - } - - if (catalogo) elem.catalogo = { ...catalogo }; - - const newElem = new MyElem({ - ...elem, // Copia le proprietà dell'elemento - _id: new mongoose.Types.ObjectId(), // Genera un nuovo ID - idPage: newPage._id.toString(), // Imposta il nuovo campo IdPage - }); - - return newElem; - }); - - // Salva tutti gli elementi duplicati - await MyElem.insertMany(duplicates); - - console.log('Duplicazione completata con successo.'); - return true; - } catch (error) { - console.error('Errore durante la duplicazione:', error); - return false; - } -} - async function exportPage(idapp, pageId) { try { const myexp = { @@ -1144,8 +1081,8 @@ router.post('/duppage', authenticate, async (req, res) => { try { let found = await MyPage.findOne({ idapp, path: mypath }) .then(async (ris) => { - const result = await duplicatePage(ris._id, newpath); - if (result) { + const result = await globalTables.duplicatePage(ris._id, newpath); + if (result && result.newpage) { return res.send({ code: server_constants.RIS_CODE_OK, msg: '' }); } else { return res.send({ code: server_constants.RIS_CODE_ERR, msg: '' }); @@ -1693,6 +1630,19 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => { } } + if (tablename === 'catalogs') { + // Devo cancellare anche la pagina associato al Catalogo! + + const myrec = await mytable.findOne({ _id: id }).lean(); + if (myrec.idPageAssigned) { + await MyPage.deleteOne({ _id: myrec.idPageAssigned }).then((rec) => { + if (!rec) { + console.log('Errore cancellazione pagina associata al catalogo'); + } + }); + } + } + let ris = null; if (!cancellato) { diff --git a/src/server/tools/general.js b/src/server/tools/general.js index b65a97f..e462091 100755 --- a/src/server/tools/general.js +++ b/src/server/tools/general.js @@ -1,5 +1,5 @@ const os = require('os'); -const fs = require('fs'); // 👈 Usa il modulo promises +const fs = require('fs-extra'); // 👈 Usa il modulo promises const xml2js = require('xml2js'); const path = require('path'); const WebSocket = require('ws'); @@ -5762,10 +5762,9 @@ module.exports = { if (table === 'catalog') { mydir = 'upload/cataloghi/'; - } + } return mydir; - }, getURLImg(idapp, table, username, img, checkifExist) { @@ -5773,12 +5772,8 @@ module.exports = { try { // let dir = this.getdirByIdApp(idapp) + dirmain + '/' + this.getDirUpload(); - let dir = - this.getdirByIdApp(idapp) - '/' + - this.getDirUpload() + - shared_consts.getDirectoryImgByTable(table, username) + - dirmain; + let dir = this.getdirByIdApp(idapp); + '/' + this.getDirUpload() + shared_consts.getDirectoryImgByTable(table, username) + dirmain; img = dir + img; @@ -6073,11 +6068,8 @@ module.exports = { if (aggiornatoimg?.filepath.includes('noimg.jpg')) { // nascondi il prodotto se non trovo l'immagine ! - await Product.updateOne( - { idProductInfo: productInfo._id }, - { $set: { deleted: true } } - ); - + await Product.updateOne({ idProductInfo: productInfo._id }, { $set: { deleted: true } }); + aggiornatoimg = { ris: false, deleted: true }; } @@ -6199,7 +6191,16 @@ module.exports = { }, async attendiNSecondi(numsec) { - await new Promise(resolve => setTimeout(resolve, numsec * 1000)); + await new Promise((resolve) => setTimeout(resolve, numsec * 1000)); + }, + + async copyDirectory(sourceDir, destinationDir) { + try { + await fs.copy(sourceDir, destinationDir); + console.log('Directory copiata con successo!'); + } catch (err) { + console.error('Errore durante la copia della directory:', err); + } }, fixFilePath(myfilepath) { diff --git a/src/server/tools/globalTables.js b/src/server/tools/globalTables.js index 336a90e..df5ed1c 100755 --- a/src/server/tools/globalTables.js +++ b/src/server/tools/globalTables.js @@ -101,186 +101,100 @@ const shared_consts = require('./shared_nodejs'); const server_constants = require('../tools/server_constants'); module.exports = { - isTableReaction(tablename) { return shared_consts.TABLES_REACTIONS.includes(tablename); }, getTableByTableName(tablename) { - let mytable = ''; - if (tablename === 'users') - mytable = User; - else if (tablename === shared_consts.TAB_MYGROUPS) - mytable = MyGroup; - else if (tablename === 'tessitura') - mytable = Tessitura; + if (tablename === 'users') mytable = User; + else if (tablename === shared_consts.TAB_MYGROUPS) mytable = MyGroup; + else if (tablename === 'tessitura') mytable = Tessitura; // else if (tablename === 'extralist') // mytable = ExtraList; - else if (tablename === 'bookings') - mytable = Booking; - else if (tablename === 'operators') - mytable = Operator; - else if (tablename === 'products') - mytable = Product; - else if (tablename === 'arrvariazioni') - mytable = Product; - else if (tablename === 'productinfos') - mytable = ProductInfo; - else if (tablename === 'storehouses') - mytable = Storehouse; - else if (tablename === 'providers') - mytable = Provider; - else if (tablename === 'gasordines') - mytable = Gasordine; - else if (tablename === 'scontisticas') - mytable = Scontistica; - else if (tablename === 'departments') - mytable = Department; - else if (tablename === 'categorys') - mytable = Category; - else if (tablename === 'catprods') - mytable = CatProd; - else if (tablename === 'collanas') - mytable = Collana; - else if (tablename === 'catais') - mytable = CatAI; - else if (tablename === 'queryais') - mytable = QueryAI; - else if (tablename === 'subcatprods') - mytable = SubCatProd; - else if (tablename === 't_web_statiprodottos') - mytable = T_Web_StatiProdotto; - else if (tablename === 't_web_tipologies') - mytable = T_Web_Tipologie; - else if (tablename === 'sharewithus') - mytable = ShareWithUs; - else if (tablename === 'sites') - mytable = Site; - else if (tablename === 'iscritticonacreis') - mytable = IscrittiConacreis; - else if (tablename === 'iscrittiarcadei') - mytable = IscrittiArcadei; - else if (tablename === 'groups') - mytable = Group; - else if (tablename === 'todos') - mytable = Todo; - else if (tablename === 'hours') - mytable = Hours; - else if (tablename === 'orders') - mytable = Order; - else if (tablename === 'cashs') - mytable = Cash; - else if (tablename === 'cashCategorys') - mytable = CashCategory; - else if (tablename === 'cashSubCategorys') - mytable = CashSubCategory; - else if (tablename === 'producers') - mytable = Producer; - else if (tablename === 'carts') - mytable = Cart; - else if (tablename === 'orderscarts') - mytable = OrdersCart; - else if (tablename === 'sendmsgs') - mytable = SendMsg; - else if (tablename === 'wheres') - mytable = Where; - else if (tablename === 'myevents') - mytable = MyEvent; - else if (tablename === 'contribtypes') - mytable = Contribtype; - else if (tablename === 'paymenttypes') - mytable = PaymentType; - else if (tablename === 'disciplines') - mytable = Discipline; - else if (tablename === 'newstosent') - mytable = Newstosent; - else if (tablename === 'gallery') - mytable = Gallery; - else if ((tablename === 'mypages') || (tablename === 'mypage')) - mytable = MyPage; - else if (tablename === 'myelems') - mytable = MyElem; - else if (tablename === 'myscrapingbooks') - mytable = MyScrapingBook; - else if (tablename === 'crons') - mytable = Cron; - else if (tablename === 'myschedas') - mytable = MyScheda; - else if (tablename === 'bots') - mytable = MyBot; - else if (tablename === 'cfgservers') - mytable = CfgServer; - else if (tablename === 'calzoom') - mytable = CalZoom; - else if (tablename === 'templemail') - mytable = TemplEmail; - else if (tablename === 'destnewsletter') - mytable = DestNewsletter; - else if (tablename === 'opzemail') - mytable = OpzEmail; - else if (tablename === 'settings') - mytable = Settings; - else if (tablename === 'permissions') - mytable = Permission; - else if (tablename === 'mailinglist') - mytable = MailingList; - else if (tablename === 'msg_templates') - mytable = MsgTemplate; - else if (tablename === 'navepersistente') - mytable = NavePersistente; + else if (tablename === 'bookings') mytable = Booking; + else if (tablename === 'operators') mytable = Operator; + else if (tablename === 'products') mytable = Product; + else if (tablename === 'arrvariazioni') mytable = Product; + else if (tablename === 'productinfos') mytable = ProductInfo; + else if (tablename === 'storehouses') mytable = Storehouse; + else if (tablename === 'providers') mytable = Provider; + else if (tablename === 'gasordines') mytable = Gasordine; + else if (tablename === 'scontisticas') mytable = Scontistica; + else if (tablename === 'departments') mytable = Department; + else if (tablename === 'categorys') mytable = Category; + else if (tablename === 'catprods') mytable = CatProd; + else if (tablename === 'collanas') mytable = Collana; + else if (tablename === 'catais') mytable = CatAI; + else if (tablename === 'queryais') mytable = QueryAI; + else if (tablename === 'subcatprods') mytable = SubCatProd; + else if (tablename === 't_web_statiprodottos') mytable = T_Web_StatiProdotto; + else if (tablename === 't_web_tipologies') mytable = T_Web_Tipologie; + else if (tablename === 'sharewithus') mytable = ShareWithUs; + else if (tablename === 'sites') mytable = Site; + else if (tablename === 'iscritticonacreis') mytable = IscrittiConacreis; + else if (tablename === 'iscrittiarcadei') mytable = IscrittiArcadei; + else if (tablename === 'groups') mytable = Group; + else if (tablename === 'todos') mytable = Todo; + else if (tablename === 'hours') mytable = Hours; + else if (tablename === 'orders') mytable = Order; + else if (tablename === 'cashs') mytable = Cash; + else if (tablename === 'cashCategorys') mytable = CashCategory; + else if (tablename === 'cashSubCategorys') mytable = CashSubCategory; + else if (tablename === 'producers') mytable = Producer; + else if (tablename === 'carts') mytable = Cart; + else if (tablename === 'orderscarts') mytable = OrdersCart; + else if (tablename === 'sendmsgs') mytable = SendMsg; + else if (tablename === 'wheres') mytable = Where; + else if (tablename === 'myevents') mytable = MyEvent; + else if (tablename === 'contribtypes') mytable = Contribtype; + else if (tablename === 'paymenttypes') mytable = PaymentType; + else if (tablename === 'disciplines') mytable = Discipline; + else if (tablename === 'newstosent') mytable = Newstosent; + else if (tablename === 'gallery') mytable = Gallery; + else if (tablename === 'mypages' || tablename === 'mypage') mytable = MyPage; + else if (tablename === 'myelems') mytable = MyElem; + else if (tablename === 'myscrapingbooks') mytable = MyScrapingBook; + else if (tablename === 'crons') mytable = Cron; + else if (tablename === 'myschedas') mytable = MyScheda; + else if (tablename === 'bots') mytable = MyBot; + else if (tablename === 'cfgservers') mytable = CfgServer; + else if (tablename === 'calzoom') mytable = CalZoom; + else if (tablename === 'templemail') mytable = TemplEmail; + else if (tablename === 'destnewsletter') mytable = DestNewsletter; + else if (tablename === 'opzemail') mytable = OpzEmail; + else if (tablename === 'settings') mytable = Settings; + else if (tablename === 'permissions') mytable = Permission; + else if (tablename === 'mailinglist') mytable = MailingList; + else if (tablename === 'msg_templates') mytable = MsgTemplate; + else if (tablename === 'navepersistente') mytable = NavePersistente; // else if (tablename === 'listaingressos') // mytable = ListaIngresso; - else if (tablename === 'graduatorias') - mytable = Graduatoria; - else if (tablename === 'skills') - mytable = Skill; - else if (tablename === 'catalogs') - mytable = Catalog; - else if (tablename === 'raccoltacataloghis') - mytable = RaccoltaCataloghi; - else if (tablename === 'goods') - mytable = Good; - else if (tablename === 'subskills') - mytable = SubSkill; - else if (tablename === shared_consts.TABLES_MYSKILLS) - mytable = MySkill; - else if (tablename === shared_consts.TABLES_ATTIVITAS) - mytable = Attivita; - else if (tablename === shared_consts.TABLES_MYBACHECAS) - mytable = MyBacheca; - else if (tablename === shared_consts.TABLES_MYHOSPS) - mytable = MyHosp; - else if (tablename === shared_consts.TABLES_MYGOODS) - mytable = MyGood; - else if (tablename === 'statusSkills') - mytable = StatusSkill; - else if (tablename === 'cities') - mytable = City; - else if (tablename === 'provinces') - mytable = Province; - else if (tablename === 'sectors') - mytable = Sector; - else if (tablename === 'sectorgoods') - mytable = SectorGood; - else if (tablename === 'catgrps') - mytable = CatGrp; - else if (tablename === 'levels') - mytable = Level; - else if (tablename === 'adtypes') - mytable = AdType; - else if (tablename === 'adtypegoods') - mytable = AdTypeGood; - else if (tablename === 'circuits') - mytable = Circuit; - else if (tablename === 'accounts') - mytable = Account; - else if (tablename === 'movements') - mytable = Movement; - else if (tablename === 'reactions') - mytable = Reaction; - else if (shared_consts.TablePickup.includes(tablename)) - mytable = Pickup; + else if (tablename === 'graduatorias') mytable = Graduatoria; + else if (tablename === 'skills') mytable = Skill; + else if (tablename === 'catalogs') mytable = Catalog; + else if (tablename === 'raccoltacataloghis') mytable = RaccoltaCataloghi; + else if (tablename === 'goods') mytable = Good; + else if (tablename === 'subskills') mytable = SubSkill; + else if (tablename === shared_consts.TABLES_MYSKILLS) mytable = MySkill; + else if (tablename === shared_consts.TABLES_ATTIVITAS) mytable = Attivita; + else if (tablename === shared_consts.TABLES_MYBACHECAS) mytable = MyBacheca; + else if (tablename === shared_consts.TABLES_MYHOSPS) mytable = MyHosp; + else if (tablename === shared_consts.TABLES_MYGOODS) mytable = MyGood; + else if (tablename === 'statusSkills') mytable = StatusSkill; + else if (tablename === 'cities') mytable = City; + else if (tablename === 'provinces') mytable = Province; + else if (tablename === 'sectors') mytable = Sector; + else if (tablename === 'sectorgoods') mytable = SectorGood; + else if (tablename === 'catgrps') mytable = CatGrp; + else if (tablename === 'levels') mytable = Level; + else if (tablename === 'adtypes') mytable = AdType; + else if (tablename === 'adtypegoods') mytable = AdTypeGood; + else if (tablename === 'circuits') mytable = Circuit; + else if (tablename === 'accounts') mytable = Account; + else if (tablename === 'movements') mytable = Movement; + else if (tablename === 'reactions') mytable = Reaction; + else if (shared_consts.TablePickup.includes(tablename)) mytable = Pickup; //else if (shared_consts.TableCities.includes(tablename)) // mytable = City; @@ -301,7 +215,8 @@ module.exports = { /// ... rivedere il crea gruppo... notifiche... try { if (!recnotif.typesend) { - recnotif.typesend = shared_consts.MessageOptions.Notify_ByPushNotification + shared_consts.MessageOptions.Notify_ByBotTelegram; + recnotif.typesend = + shared_consts.MessageOptions.Notify_ByPushNotification + shared_consts.MessageOptions.Notify_ByBotTelegram; } let invia = false; @@ -326,7 +241,10 @@ module.exports = { linkaddTelegram: recnotif.linkaddTelegram ? recnotif.linkaddTelegram : '', }; - if (tools.isBitActive(recnotif.typesend, shared_consts.MessageOptions.Notify_ByPushNotification) && this.checkifSendPushNotification) { + if ( + tools.isBitActive(recnotif.typesend, shared_consts.MessageOptions.Notify_ByPushNotification) && + this.checkifSendPushNotification + ) { params.typesend = params.typesend + shared_consts.TypeSend.PUSH_NOTIFICATION; invia = true; } @@ -335,7 +253,6 @@ module.exports = { invia = true; } - if (invia) { ris = await this.SendMsgToParam(idapp, params); } @@ -344,8 +261,7 @@ module.exports = { if (tools.isBitActive(recnotif.typesend, shared_consts.MessageOptions.Notify_ByEmail)) { // Read from the operator table first let emaildest = await Operator.getEmailByUsername(recnotif.dest.idapp, recnotif.dest.username); - if (!emaildest) - emaildest = await User.getEmailByUsername(recnotif.dest.idapp, recnotif.dest.username); + if (!emaildest) emaildest = await User.getEmailByUsername(recnotif.dest.idapp, recnotif.dest.username); await sendemail.sendEmail_ByNotif(res, user.lang, emaildest, user, idapp, recnotif); } @@ -358,7 +274,6 @@ module.exports = { }, SendMsgToParam: async function (idapp, params) { - try { // console.log('SendMsgToParam', params.typesend, params.typemsg); @@ -368,8 +283,7 @@ module.exports = { const telegrambot = require('../telegram/telegrambot'); - if (params.typesend === 0) - params.typesend = shared_consts.TypeSend.PUSH_NOTIFICATION; + if (params.typesend === 0) params.typesend = shared_consts.TypeSend.PUSH_NOTIFICATION; let query = { idapp }; let addquery = {}; @@ -380,8 +294,7 @@ module.exports = { addquery = {}; } else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_SOCI) { addquery = { 'profile.socio': true }; - } else if (params.typemsg === - shared_consts.TypeMsg.SEND_TO_SOCIO_RESIDENTE) { + } else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_SOCIO_RESIDENTE) { addquery = { 'profile.socioresidente': true }; } else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_CONSIGLIO) { addquery = { 'profile.consiglio': true }; @@ -398,14 +311,15 @@ module.exports = { 'profile.teleg_id': { $gt: 1 }, $or: [ { 'profile.username_telegram': { $exists: false } }, - { 'profile.username_telegram': { $exists: true, $eq: '' } }], + { 'profile.username_telegram': { $exists: true, $eq: '' } }, + ], }; } else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_TELEG_NO_VERIF_BY_APORTADOR) { addquery = { 'profile.teleg_id': { $gt: 1 }, 'profile.username_telegram': { $exists: true }, $expr: { $gt: [{ $strLenCP: '$profile.username_telegram' }, 3] }, - 'verified_by_aportador': { $exists: false }, + verified_by_aportador: { $exists: false }, }; } else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_GROUP) { if (params.groupnameDest) { @@ -434,26 +348,24 @@ module.exports = { let text = ''; if (invia) { - const allquery = { ...query, ...addquery }; - let arrusers = await User.find( - allquery, - { - username: 1, - 'profile.teleg_id': 1, - 'profile.notifs': 1, - }, - ).lean(); + let arrusers = await User.find(allquery, { + username: 1, + 'profile.teleg_id': 1, + 'profile.notifs': 1, + }).lean(); if (!tools.sulServer()) { arrusers = await User.find({ idapp, username: shared_consts.ADMIN_USER_SERVER }); } for (const user of arrusers) { - const mytitle = await tools.convertSpecialTags(user, params.title); - const mycontent = await tools.convertSpecialTags(user, params.textcontent_Telegram ? params.textcontent_Telegram : params.content); + const mycontent = await tools.convertSpecialTags( + user, + params.textcontent_Telegram ? params.textcontent_Telegram : params.content + ); let usernotifprofile = null; if (user.profile.notifs) @@ -464,7 +376,11 @@ module.exports = { let sendmsg = false; if (params.typenotif === shared_consts.TypeNotifs.TYPEDIR_FAVORITE) { - if (!usernotifprofile || (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.TypeNotifs.ID_FAVORITE_ADDED))) { + if ( + !usernotifprofile || + (usernotifprofile && + tools.isBitActive(usernotifprofile.value, shared_consts.TypeNotifs.ID_FAVORITE_ADDED)) + ) { sendmsg = true; } } else { @@ -475,31 +391,42 @@ module.exports = { if (params.sendreally) { if (tools.isBitActive(params.typesend, shared_consts.TypeSend.PUSH_NOTIFICATION)) { const myparam = { ...params }; - risult = await tools.sendNotificationToUser(user._id, mytitle, mycontent, myparam.openUrl, myparam.openUrl2, myparam.tag, - myparam.actions, myparam.id). - then(ris => { - - }). - catch(e => { + risult = await tools + .sendNotificationToUser( + user._id, + mytitle, + mycontent, + myparam.openUrl, + myparam.openUrl2, + myparam.tag, + myparam.actions, + myparam.id + ) + .then((ris) => {}) + .catch((e) => { console.error(e.message); }); - } if (tools.isBitActive(params.typesend, shared_consts.TypeSend.TELEGRAM)) { const telegid = user.profile.teleg_id; text = tools.getContentNotifByParams(params, mycontent, shared_consts.TypeSend.TELEGRAM); if (telegid > 0) { - risult = await telegrambot.local_sendMsgTelegramByIdTelegram(idapp, telegid, text, undefined, undefined, undefined, undefined, params.img); + risult = await telegrambot.local_sendMsgTelegramByIdTelegram( + idapp, + telegid, + text, + undefined, + undefined, + undefined, + undefined, + params.img + ); await tools.snooze(25); try { - if (risult && (risult.text || risult.caption)) - textsent = (risult.text || risult.caption); - } catch (e) { - - } - + if (risult && (risult.text || risult.caption)) textsent = risult.text || risult.caption; + } catch (e) {} } } } @@ -509,7 +436,7 @@ module.exports = { nummsgsent++; } - if (nummsgsent > 0 && (nummsgsent % 100) === 0) { + if (nummsgsent > 0 && nummsgsent % 100 === 0) { console.log('Inviati ', nummsgsent, 'messaggi...'); } } @@ -517,7 +444,7 @@ module.exports = { } if (nummsgsent > 0) { - if (nummsgsent != numrec && (numrec !== 1)) + if (nummsgsent != numrec && numrec !== 1) console.log('FINE Invio Messaggi ! Inviati Totali: ', nummsgsent, 'su', numrec); } @@ -530,11 +457,9 @@ module.exports = { } catch (e) { console.error('SendMsgToParam', e); } - }, SendMsgToAll: async function (idapp, params) { - params.typemsg = shared_consts.TypeMsg.SEND_TO_ALL; params.sendreally = true; params.typesend = shared_consts.TypeSend.PUSH_NOTIFICATION; @@ -547,28 +472,29 @@ module.exports = { let result = ''; let resultPrima = ''; - if (!searchString) - return ''; + if (!searchString) return ''; try { // Ottieni tutte le collezioni del database const collections = await db.listCollections().toArray(); - const collectionNames = collections.map(collection => collection.name); + const collectionNames = collections.map((collection) => collection.name); for (const collectionName of collectionNames) { // Crea l'indice di testo per la collezione - await db.collection(collectionName).createIndex({ "$**": "text" }); + await db.collection(collectionName).createIndex({ '$**': 'text' }); if (collectionName !== 'sendnotifs') { // Cerca nella collezione - const found = await db.collection(collectionName).find({ - $and: [ - { idapp: idapp }, - { $text: { $search: searchString } }, - { 'profile.username_telegram': { $exists: false } } - ] - }).toArray(); - + const found = await db + .collection(collectionName) + .find({ + $and: [ + { idapp: idapp }, + { $text: { $search: searchString } }, + { 'profile.username_telegram': { $exists: false } }, + ], + }) + .toArray(); if (found.length > 0) { resultPrima += `Risultati trovati nella collezione: ${collectionName} (${found.length} record)\n`; @@ -588,45 +514,42 @@ module.exports = { } catch (error) { result = `Errore durante la ricerca: ${error.message}`; } finally { - } return resultPrima + '\n\n' + result; }, replaceAportadorSolidario: async function (idapp, search_username, replace_username) { - - console.log('INIZIO replaceAportadorSolidario') + console.log('INIZIO replaceAportadorSolidario'); if (!search_username || !replace_username) { return false; } - ris = await User.updateMany({ idapp, aportador_iniziale: search_username }, + ris = await User.updateMany( + { idapp, aportador_iniziale: search_username }, { - $set: - { aportador_iniziale: replace_username } - }); + $set: { aportador_iniziale: replace_username }, + } + ); console.log('aportador_iniziale result = ', ris); - ris = await User.updateMany({ idapp, aportador_solidario: search_username }, + ris = await User.updateMany( + { idapp, aportador_solidario: search_username }, { - $set: - { aportador_solidario: replace_username } - }); + $set: { aportador_solidario: replace_username }, + } + ); console.log('aportador_solidario result = ', ris); - }, replaceUsername: async function (idapp, search_username, replace_username) { - if (!search_username || !replace_username) { return false; } const test = false; - - console.log('INIZIO replaceUsername') + console.log('INIZIO replaceUsername'); try { let ris = null; @@ -634,179 +557,201 @@ module.exports = { const dir = tools.getdirByIdApp(idapp, true); - tools.move(dir + server_constants.DIR_UPLOAD + '/profile/' + search_username, dir + server_constants.DIR_UPLOAD + '/profile/' + replace_username, function callback() { - console.log(' ... moved dir', dir + server_constants.DIR_UPLOAD + '/profile/' + search_username, dir + server_constants.DIR_UPLOAD + '/profile/' + replace_username); - }); + tools.move( + dir + server_constants.DIR_UPLOAD + '/profile/' + search_username, + dir + server_constants.DIR_UPLOAD + '/profile/' + replace_username, + function callback() { + console.log( + ' ... moved dir', + dir + server_constants.DIR_UPLOAD + '/profile/' + search_username, + dir + server_constants.DIR_UPLOAD + '/profile/' + replace_username + ); + } + ); if (test) { // esco... - } else { - - ris = await User.findOneAndUpdate({ idapp, username: search_username }, { $set: { username: replace_username } }); + ris = await User.findOneAndUpdate( + { idapp, username: search_username }, + { $set: { username: replace_username } } + ); console.log('username result = ', ris); - ris = await User.findOneAndUpdate({ idapp, username: search_username }, { $set: { username: replace_username } }); + ris = await User.findOneAndUpdate( + { idapp, username: search_username }, + { $set: { username: replace_username } } + ); console.log('username result = ', ris); - ris = await User.findOneAndUpdate({ idapp, 'profile.username_telegram': search_username }, { $set: { 'profile.username_telegram': replace_username } }); + ris = await User.findOneAndUpdate( + { idapp, 'profile.username_telegram': search_username }, + { $set: { 'profile.username_telegram': replace_username } } + ); console.log('profile.username_telegram result = ', ris); - ris = await User.updateMany({ idapp, aportador_iniziale: search_username }, + ris = await User.updateMany( + { idapp, aportador_iniziale: search_username }, { - $set: - { aportador_iniziale: replace_username } - }); + $set: { aportador_iniziale: replace_username }, + } + ); console.log('aportador_iniziale result = ', ris); - ris = await User.updateMany({ idapp, username_who_report: search_username }, + ris = await User.updateMany( + { idapp, username_who_report: search_username }, { - $set: - { username_who_report: replace_username } - }); + $set: { username_who_report: replace_username }, + } + ); console.log('username_who_report result = ', ris); - ris = await User.updateMany({ idapp, aportador_solidario: search_username }, + ris = await User.updateMany( + { idapp, aportador_solidario: search_username }, { - $set: - { aportador_solidario: replace_username } - }); + $set: { aportador_solidario: replace_username }, + } + ); console.log('aportador_solidario result = ', ris); - ris = await User.updateMany({ idapp, 'profile.friends.username': search_username }, + ris = await User.updateMany( + { idapp, 'profile.friends.username': search_username }, { - $set: - { 'profile.friends.$.username': replace_username } - }); + $set: { 'profile.friends.$.username': replace_username }, + } + ); console.log('friends.username result = ', ris); - ris = await User.updateMany({ idapp, 'profile.req_friends.username': search_username }, + ris = await User.updateMany( + { idapp, 'profile.req_friends.username': search_username }, { - $set: - { 'profile.req_friends.$.username': replace_username } - }); + $set: { 'profile.req_friends.$.username': replace_username }, + } + ); console.log('req_friends.username result = ', ris); - ris = await User.updateMany({ idapp, 'profile.handshake.username': search_username }, + ris = await User.updateMany( + { idapp, 'profile.handshake.username': search_username }, { - $set: - { 'profile.handshake.$.username': replace_username } - }); + $set: { 'profile.handshake.$.username': replace_username }, + } + ); console.log('handshake.username result = ', ris); - ris = await Circuit.updateMany({ idapp, 'admins.username': search_username }, - { $set: { 'admins.$.username': replace_username } }); + ris = await Circuit.updateMany( + { idapp, 'admins.username': search_username }, + { $set: { 'admins.$.username': replace_username } } + ); console.log('Circuit.admins.username result = ', ris); - ris = await Circuit.updateMany({ idapp, 'createdBy': search_username }, - { $set: { 'createdBy': replace_username } }); + ris = await Circuit.updateMany( + { idapp, createdBy: search_username }, + { $set: { createdBy: replace_username } } + ); console.log('Circuit.createdBy result = ', ris); - ris = await MyGroup.updateMany({ idapp, 'createdBy': search_username }, - { $set: { 'createdBy': replace_username } }); + ris = await MyGroup.updateMany( + { idapp, createdBy: search_username }, + { $set: { createdBy: replace_username } } + ); console.log('MyGroup.createdBy result = ', ris); ris = await MyElem.updateMany( { idapp, $or: [ - { 'containerHtml': { $regex: search_username, $options: 'i' } }, - { 'link': { $regex: search_username, $options: 'i' } } - ] + { containerHtml: { $regex: search_username, $options: 'i' } }, + { link: { $regex: search_username, $options: 'i' } }, + ], }, [ { $set: { containerHtml: { $replaceAll: { - input: "$containerHtml", + input: '$containerHtml', find: search_username, - replacement: replace_username - } + replacement: replace_username, + }, }, link: { $replaceAll: { - input: "$link", + input: '$link', find: search_username, - replacement: replace_username - } - } - } - } + replacement: replace_username, + }, + }, + }, + }, ] ); console.log('MyElem.containerHtml result = ', ris); - ris = await Circuit.updateMany({ idapp, 'req_users.username': search_username }, - { $set: { 'req_users.$.username': replace_username } }); + ris = await Circuit.updateMany( + { idapp, 'req_users.username': search_username }, + { $set: { 'req_users.$.username': replace_username } } + ); console.log('Circuit.req_users.username result = ', ris); - ris = await Circuit.updateMany({ idapp, 'refused_users.username': search_username }, - { $set: { 'refused_users.$.username': replace_username } }); + ris = await Circuit.updateMany( + { idapp, 'refused_users.username': search_username }, + { $set: { 'refused_users.$.username': replace_username } } + ); console.log('Circuit.refused_users.username result = ', ris); - ris = await Account.updateMany({ idapp, 'username': search_username }, - { $set: { 'username': replace_username } }); + ris = await Account.updateMany({ idapp, username: search_username }, { $set: { username: replace_username } }); console.log('Account.username result = ', ris); - ris = await MyGroup.updateMany({ idapp, 'admins.username': search_username }, - { $set: { 'admins.$.username': replace_username } }); + ris = await MyGroup.updateMany( + { idapp, 'admins.username': search_username }, + { $set: { 'admins.$.username': replace_username } } + ); console.log('MyGroup.refused_users.username result = ', ris); - ris = await MyGroup.updateMany({ idapp, 'req_users.username': search_username }, - { $set: { 'req_users.$.username': replace_username } }); + ris = await MyGroup.updateMany( + { idapp, 'req_users.username': search_username }, + { $set: { 'req_users.$.username': replace_username } } + ); console.log('MyGroup.req_users.username result = ', ris); // MyGroup.refused_users.username - ris = await MyGroup.updateMany({ idapp, 'refused_users.username': search_username }, - { $set: { 'refused_users.$.username': replace_username } }); + ris = await MyGroup.updateMany( + { idapp, 'refused_users.username': search_username }, + { $set: { 'refused_users.$.username': replace_username } } + ); console.log('MyGroup.refused_users.username result = ', ris); const { SendNotif } = require('../models/sendnotif'); - ris = await SendNotif.updateMany({ idapp, 'sender': search_username }, - { $set: { 'sender': replace_username } }); + ris = await SendNotif.updateMany({ idapp, sender: search_username }, { $set: { sender: replace_username } }); console.log('SendNotif.sender result = ', ris); try { - - ris = await SendNotif.updateMany({ idapp, 'dest': search_username }, - { $set: { 'dest': replace_username } }); + ris = await SendNotif.updateMany({ idapp, dest: search_username }, { $set: { dest: replace_username } }); console.log('SendNotif.dest result = ', ris); } catch (e) { console.error(e); } - ris = await Reaction.updateMany({ idapp, 'username': search_username }, - { $set: { 'username': replace_username } }); + ris = await Reaction.updateMany({ idapp, username: search_username }, { $set: { username: replace_username } }); console.log('Reaction.dest result = ', ris); - ris = await SendMsg.updateMany({ idapp, 'dest': search_username }, - { $set: { 'dest': replace_username } }); + ris = await SendMsg.updateMany({ idapp, dest: search_username }, { $set: { dest: replace_username } }); console.log('SendMsg.dest result = ', ris); - ris = await SendMsg.updateMany({ idapp, 'origin': search_username }, - { $set: { 'origin': replace_username } }); + ris = await SendMsg.updateMany({ idapp, origin: search_username }, { $set: { origin: replace_username } }); console.log('SendMsg.origin result = ', ris); - - ris = await Booking.updateMany({ idapp, 'username': search_username }, - { $set: { 'username': replace_username } }); + ris = await Booking.updateMany({ idapp, username: search_username }, { $set: { username: replace_username } }); console.log('Booking.username result = ', ris); - } - - - } catch (e) { console.error(e); } - }, getNumFavoriteByIdObj: async function (idapp, numtab, id) { - const { Reaction } = require('../models/reaction'); let query = [ @@ -817,21 +762,20 @@ module.exports = { }, }, { - $group: - { + $group: { _id: null, count: { $sum: { $cond: { - if: { $ifNull: ["$fav", false] }, // Check if the field exists and is not null + if: { $ifNull: ['$fav', false] }, // Check if the field exists and is not null then: 1, // Increment count by 1 if the field exists else: 0, // Otherwise, keep the count unchanged - } - } + }, + }, }, - } + }, }, - { $project: { _id: 0 } } + { $project: { _id: 0 } }, ]; try { @@ -843,11 +787,9 @@ module.exports = { } return 0; - }, getNumBookByIdObj: async function (idapp, numtab, id) { - const { Reaction } = require('../models/reaction'); let query = [ @@ -858,21 +800,20 @@ module.exports = { }, }, { - $group: - { + $group: { _id: null, count: { $sum: { $cond: { - if: { $ifNull: ["$book", false] }, // Check if the field exists and is not null + if: { $ifNull: ['$book', false] }, // Check if the field exists and is not null then: 1, // Increment count by 1 if the field exists else: 0, // Otherwise, keep the count unchanged - } - } + }, + }, }, - } + }, }, - { $project: { _id: 0 } } + { $project: { _id: 0 } }, ]; try { @@ -884,11 +825,9 @@ module.exports = { } return 0; - }, getNumAttendByIdObj: async function (idapp, numtab, id) { - const { Reaction } = require('../models/reaction'); let query = [ @@ -899,16 +838,15 @@ module.exports = { }, }, { - $group: - { + $group: { _id: null, count: { $sum: { $cond: { - if: { $ifNull: ["$attent", false] }, // Check if the field exists and is not null + if: { $ifNull: ['$attent', false] }, // Check if the field exists and is not null then: 1, // Increment count by 1 if the field exists else: 0, // Otherwise, keep the count unchanged - } + }, }, /*$sum: @@ -922,9 +860,9 @@ module.exports = { } }*/ }, - } + }, }, - { $project: { _id: 0 } } + { $project: { _id: 0 } }, ]; try { @@ -952,12 +890,20 @@ module.exports = { let numfav = await this.getNumFavoriteByIdObj(idapp, numtab, id); let numbook = await this.getNumBookByIdObj(idapp, numtab, id); let exist = false; - if (table === shared_consts.TABLES_MYBACHECAS) - exist = numattend > 1; - else - exist = numfav > 1; + if (table === shared_consts.TABLES_MYBACHECAS) exist = numattend > 1; + else exist = numfav > 1; if (recuser) - return { userId: rec.userId, username: recuser.username, descr: rec.descr, id: rec._id, table, exist, numfav, numattend, numbook }; + return { + userId: rec.userId, + username: recuser.username, + descr: rec.descr, + id: rec._id, + table, + exist, + numfav, + numattend, + numbook, + }; } } } catch (e) { @@ -972,7 +918,6 @@ module.exports = { if (true) { res.status(408).send({}); - } }, @@ -998,21 +943,222 @@ module.exports = { { $pull: { 'profile.mycircuits': { circuitname: nomecircuito } } } ); - if (ris) - console.log(`L'username ${username} è stato rimosso dagli admins di ` + nomecircuito); + if (ris) console.log(`L'username ${username} è stato rimosso dagli admins di ` + nomecircuito); } } else { console.log(`Nessun account trovato con saldo_pend a zero per l'username: ${username}.`); } } catch (error) { - console.error('Errore durante l\'operazione:', error); + console.error("Errore durante l'operazione:", error); } }, async ExitFromAllCircuitWithZero(idapp, username) { return await this.removeAdminIfZeroBalance(idapp, username); - }, + async clonePage(idapp, idPageOrig, newName, newPath) { + try { + // Recupera la pagina originale + const page = await MyPage.findOne({ _id: idPageOrig }).lean(); + if (!page) { + console.log('Pagina originale non trovata.'); + return; + } + + // Clona la pagina rimuovendo l'_id e aggiungendo un nuovo nome + const clonedPage = { + ...page, _id: new mongoose.Types.ObjectId(), + title: newName, + path: newPath, + isTemplate: false, + }; + + // Salva la pagina clonata + const savedPage = await MyPage.create(clonedPage); + console.log('Pagina clonata con successo:', savedPage._id); + return savedPage; + } catch (error) { + console.error('Errore durante la clonazione della pagina:', error); + } + }, + + async cloneCatalog(idapp, idOrig, newName, idPageAssigned) { + try { + // Recupera il catalogo originale + const mycatalog = await Catalog.findOne({ idapp, _id: idOrig }).lean(); + if (!mycatalog) { + console.log('Catalogo originale non trovato.'); + return; + } + + // Clona la pagina rimuovendo l'_id e aggiungendo un nuovo nome + const clonedCatalog = { + _id: new mongoose.Types.ObjectId(), + idapp, + active: true, + title: newName, + foto_collana: mycatalog.foto_collana, + idCollane: mycatalog.idCollane, + idTipoFormato: mycatalog.idTipoFormato, + argomenti: mycatalog.argomenti, + condition_andor: mycatalog.condition_andor, + editore: mycatalog.editore, + editore_escludi: mycatalog.editore_escludi, + descr_introduttiva: '', + img_bordata: mycatalog.img_bordata, + img_intro: mycatalog.img_intro, + img_bordata_stampa: mycatalog.img_bordata_stampa, + img_intro_stampa: mycatalog.img_intro_stampa, + pagina_introduttiva_sfondo_nero: mycatalog.pagina_introduttiva_sfondo_nero, + backcolor: mycatalog.backcolor, + idPageAssigned: idPageAssigned, + }; + + const mydirpath = tools.getdirByIdApp(idapp); + + // copia i file nella sua sottocartella del catalogo + const sourceDir = path.join(mydirpath, tools.getDirUpload(), shared_consts.getDirectoryByTable(shared_consts.TABLES_CATALOG), idOrig); + const destinationDir = path.join(mydirpath, tools.getDirUpload(), shared_consts.getDirectoryByTable(shared_consts.TABLES_CATALOG), clonedCatalog._id.toString()); + + await tools.copyDirectory(sourceDir, destinationDir); + + // Salva la pagina clonata + const savedCatalog = await Catalog.create(clonedCatalog); + + return savedCatalog; + console.log('Catalogo clonato con successo:', savedCatalog._id); + } catch (error) { + console.error('Errore durante la clonazione del Catalogo:', error); + } + }, + + async newEmptyCatalog(idapp, newName, idPageAssigned) { + try { + + const clonedCatalog = { + _id: new mongoose.Types.ObjectId(), + active: true, + title: newName, + idPageAssigned: idPageAssigned, + }; + + // Salva la pagina + const savedCatalog = await Catalog.create(clonedCatalog); + + return savedCatalog; + console.log('Catalogo creato con successo:', savedCatalog._id); + } catch (error) { + console.error('Errore durante la clonazione del Catalogo:', error); + } + }, + + async duplicatePage(pageId, newpath, title = '') { + try { + // Trova il record di Page da duplicare + const pageToDuplicate = await MyPage.findById(pageId); + if (!pageToDuplicate) { + console.error('Page not found.'); + return; + } + + // Crea una copia del record di Page + const newPage = new MyPage({ + ...pageToDuplicate.toObject(), // Converte il documento Moongose in oggetto + _id: new mongoose.Types.ObjectId(), // Genera un nuovo ID + // modifiche ai campi se necessario, per esempio: + path: newpath, + title: title || newpath, + inmenu: false, + active: true, + date_updated: new Date(), + }); + + // Salva il nuovo record di Page + await newPage.save(); + + // Trova tutti gli elementi associati a Page da duplicare + const elemsToDuplicate = await MyElem.find({ idPage: pageId }).lean(); + + // Duplica ogni elemento utilizzando il nuovo idPath + const duplicates = elemsToDuplicate.map((elem) => { + const catalogo = elem.catalogo; + + if (catalogo) { + for (const recscheda of catalogo.arrSchede) { + if (recscheda.scheda?.isTemplate) { + // Se è un template allora devo mettergli un altro ID ! + recscheda.scheda._id = new mongoose.Types.ObjectId(); + // recscheda.scheda.name = getNewFreeNameTemplate(recscheda.scheda?.name) + } + } + } + + if (catalogo) elem.catalogo = { ...catalogo }; + + const newElem = new MyElem({ + ...elem, // Copia le proprietà dell'elemento + _id: new mongoose.Types.ObjectId(), // Genera un nuovo ID + idPage: newPage._id.toString(), // Imposta il nuovo campo IdPage + path: newPage.path, + }); + + return newElem; + }); + + // Salva tutti gli elementi duplicati + await MyElem.insertMany(duplicates); + + const newElems = await MyElem.find({ idPage: newPage._id }).lean(); + + console.log('Duplicazione completata con successo.'); + const newPageOut = await MyPage.findById(newPage._id).lean(); + + return { newPage: newPageOut, newElems }; + + } catch (error) { + console.error('Errore durante la duplicazione:', error); + return { newPage: null, newElems: null }; + } + }, + + async addNewCatalog(idapp, newCatalog) { + try { + if (newCatalog) { + const myNewrecs = await this.duplicatePage(newCatalog.idPageTemplate, newCatalog.path, newCatalog.title); + // Clonare la pagina MyPage che rappresenta il modello newCatalog.idPageTemplate su newCatalog.path + if (!myNewrecs?.newPage) { + console.error('Errore durante la clonazione della pagina del catalogo'); + return { newPage: null, newCatalog: null, newElems: null }; + } + + let mynewCatalog = null; + + if (newCatalog.idCatalogToCopy) { + + mynewCatalog = await this.cloneCatalog( + idapp, + newCatalog.idCatalogToCopy, + newCatalog.title, + myNewrecs?.newPage._id + ); + } else { + mynewCatalog = await this.newEmptyCatalog( + idapp, + newCatalog.title, + myNewrecs?.newPage._id + ); + + } + + return { newPage: myNewrecs?.newPage, newElems: myNewrecs?.newElems, newCatalog: mynewCatalog }; + } + } catch (e) { + console.error("Errore durante l'aggiunta del catalogo:", e); + return { newPage: null, newCatalog: null, newElems: null }; + } +}, + + };