- 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: { visibile: {
type: Boolean type: Boolean
}, },
adType: {
type: Number,
},
typeHosp: { // scambio casa / ospitalità typeHosp: { // scambio casa / ospitalità
type: Number, 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 () { MyHospSchema.statics.getProject = function () {
let proj = { let proj = {
visibile: 1, visibile: 1,

View File

@@ -1448,6 +1448,10 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
} else if (mydata.dbop === 'SvuotaTuttiGliAccessiOnlineConToken') { } else if (mydata.dbop === 'SvuotaTuttiGliAccessiOnlineConToken') {
await User.SvuotaTuttiGliAccessiOnlineConToken(idapp); 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') { } else if (mydata.dbop === 'removeRegulations') {
await Circuit.updateMany({}, { $set: { regulation: '' } }); await Circuit.updateMany({}, { $set: { regulation: '' } });

View File

@@ -5134,11 +5134,16 @@ module.exports = {
else if (myrec.adType === shared_consts.AdType.CERCO) else if (myrec.adType === shared_consts.AdType.CERCO)
tiposcambio = 'Cerco'; tiposcambio = 'Cerco';
} else if (tablerec === shared_consts.TABLES_MYHOSPS) { } else if (tablerec === shared_consts.TABLES_MYHOSPS) {
tiposcambio = 'Offro '; iconascambio = this.getIconByAdType(myrec.adType);
if (myrec.adType === shared_consts.AdType.CERCO)
tiposcambio = 'Cerco';
else
tiposcambio = 'Offro';
if (myrec.typeHosp === shared_consts.TYPEHOSP_OSPITALITA) if (myrec.typeHosp === shared_consts.TYPEHOSP_OSPITALITA)
tiposcambio += 'Ospitalità'; tiposcambio += ' Ospitalità';
else if (myrec.typeHosp === shared_consts.TYPEHOSP_SCAMBIOCASA) else if (myrec.typeHosp === shared_consts.TYPEHOSP_SCAMBIOCASA)
tiposcambio += 'Scambio Casa'; tiposcambio += ' Scambio Casa';
} else if (tablerec === shared_consts.TABLES_MYBACHECAS) { } else if (tablerec === shared_consts.TABLES_MYBACHECAS) {
datastr = this.getstrDateTimeEvent(myrec); datastr = this.getstrDateTimeEvent(myrec);
organizedby = myrec.organisedBy; organizedby = myrec.organisedBy;

View File

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