- fix: Errore se premevo "Aggiungi" e poi "Annulla" poi la tabella non si aggiornava piu.

This commit is contained in:
Surya Paolo
2024-09-30 00:05:47 +02:00
parent 6289a2e2d2
commit 7dac44e0ff
4 changed files with 29 additions and 3 deletions

View File

@@ -30,6 +30,9 @@ const MyHospSchema = new Schema({
visibile: {
type: Boolean
},
adType: {
type: Number,
},
typeHosp: { // scambio casa / ospitalità
type: Number,
},
@@ -327,6 +330,19 @@ MyHospSchema.statics.getCompleteRecord = function (idapp, id) {
};
MyHospSchema.statics.SettaAdTypeOffro_In_Hosps = function () {
const MyHosp = this;
// Set all records 'adType' to shared_consts.AdType.OFFRO
MyHosp.updateMany({}, { $set: { adType: shared_consts.AdType.OFFRO } }, function (err, result) {
if (err) {
console.error('Error updating adType:', err);
} else {
console.log('Successfully updated adType for', result.nModified, 'records');
}
});
};
MyHospSchema.statics.getProject = function () {
let proj = {
visibile: 1,

View File

@@ -1448,6 +1448,10 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
} else if (mydata.dbop === 'SvuotaTuttiGliAccessiOnlineConToken') {
await User.SvuotaTuttiGliAccessiOnlineConToken(idapp);
} else if (mydata.dbop === 'SettaAdTypeOffro_In_Hosps') {
const { MyHosp } = require('../models/myhosp');
await MyHosp.SettaAdTypeOffro_In_Hosps(idapp);
} else if (mydata.dbop === 'removeRegulations') {
await Circuit.updateMany({}, { $set: { regulation: '' } });

View File

@@ -5134,7 +5134,12 @@ module.exports = {
else if (myrec.adType === shared_consts.AdType.CERCO)
tiposcambio = 'Cerco';
} else if (tablerec === shared_consts.TABLES_MYHOSPS) {
iconascambio = this.getIconByAdType(myrec.adType);
if (myrec.adType === shared_consts.AdType.CERCO)
tiposcambio = 'Cerco';
else
tiposcambio = 'Offro';
if (myrec.typeHosp === shared_consts.TYPEHOSP_OSPITALITA)
tiposcambio += ' Ospitalità';
else if (myrec.typeHosp === shared_consts.TYPEHOSP_SCAMBIOCASA)

View File

@@ -857,6 +857,7 @@ module.exports = {
} else if (table === this.TABLES_MYHOSPS) {
proj = {
visibile: 1,
adType: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,