- fix: se salvavo un record 'settable' e non era completo con tutti i campi, andava a troncare gli altri precedentemente inseriti
- ordinamento Circuiti per stato e numiscritti e descr
This commit is contained in:
@@ -9,6 +9,9 @@
|
|||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"search.useIgnoreFiles": false,
|
"search.useIgnoreFiles": false,
|
||||||
"search.useParentIgnoreFiles": false
|
"search.useParentIgnoreFiles": false,
|
||||||
|
"files.exclude": {
|
||||||
|
"": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,9 +225,7 @@ CircuitSchema.statics.findAllIdApp = async function (idapp) {
|
|||||||
|
|
||||||
const whatToShow = this.getWhatToShow(idapp, '');
|
const whatToShow = this.getWhatToShow(idapp, '');
|
||||||
|
|
||||||
return await Circuit.find(myfind, whatToShow, (err, arrrec) => {
|
return await Circuit.find(myfind, whatToShow).sort({status: -1, numMembers: -1, name: 1});
|
||||||
return arrrec;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CircuitSchema.statics.getFieldsForSearch = function () {
|
CircuitSchema.statics.getFieldsForSearch = function () {
|
||||||
@@ -372,14 +370,14 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
|||||||
$or: [
|
$or: [
|
||||||
{ deleted: { $exists: false } },
|
{ deleted: { $exists: false } },
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
}).lean();
|
}).sort({status: -1, numMembers: -1, name: 1}).lean();
|
||||||
|
|
||||||
let listcircuits = await Circuit.find({
|
let listcircuits = await Circuit.find({
|
||||||
idapp,
|
idapp,
|
||||||
$or: [
|
$or: [
|
||||||
{ deleted: { $exists: false } },
|
{ deleted: { $exists: false } },
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
}, whatToShow_Unknown).lean();
|
}, whatToShow_Unknown).sort({status: -1, numMembers: -1, name: 1}).lean();
|
||||||
|
|
||||||
let asked_circuits = await Circuit.find({
|
let asked_circuits = await Circuit.find({
|
||||||
idapp,
|
idapp,
|
||||||
@@ -389,7 +387,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
|||||||
$or: [
|
$or: [
|
||||||
{ deleted: { $exists: false } },
|
{ deleted: { $exists: false } },
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
}, whatToShow_Unknown).lean();
|
}, whatToShow_Unknown).sort({status: -1}).lean();
|
||||||
|
|
||||||
let refused_circuits = await Circuit.find({
|
let refused_circuits = await Circuit.find({
|
||||||
idapp,
|
idapp,
|
||||||
@@ -399,7 +397,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
|||||||
$or: [
|
$or: [
|
||||||
{ deleted: { $exists: false } },
|
{ deleted: { $exists: false } },
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
}, whatToShow_Unknown).lean();
|
}, whatToShow_Unknown).sort({status: -1}).lean();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
listcircuits,
|
listcircuits,
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
|||||||
} else {
|
} else {
|
||||||
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined)) {
|
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined)) {
|
||||||
mytablerec._id = new ObjectID();
|
mytablerec._id = new ObjectID();
|
||||||
|
mydata._id = new ObjectID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,12 +402,31 @@ router.post('/settable', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
if (shared_consts.TABLES_UPDATE_LASTMODIFIED.includes(params.table)) {
|
if (shared_consts.TABLES_UPDATE_LASTMODIFIED.includes(params.table)) {
|
||||||
mytablerec.date_updated = new Date();
|
mytablerec.date_updated = new Date();
|
||||||
|
mydata.date_updated = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('mydata',mydata);
|
// console.log('mydata',mydata);
|
||||||
|
// return await mytablerec.save().
|
||||||
|
// then(async (rec) => {
|
||||||
|
|
||||||
return await mytablerec.save().
|
const myPromise = new Promise((resolve, reject) => {
|
||||||
then(async (rec) => {
|
resolve(mytablerec._id && mytable.findById(mytablerec._id))
|
||||||
|
});
|
||||||
|
|
||||||
|
return await myPromise
|
||||||
|
.then(async (doupdate) => {
|
||||||
|
if (doupdate)
|
||||||
|
return mytable.updateOne({ _id: mytablerec._id }, mydata, { new: true })
|
||||||
|
else
|
||||||
|
return mytablerec.save()
|
||||||
|
})
|
||||||
|
.then(async (risult) => {
|
||||||
|
let rec = null;
|
||||||
|
if (risult && risult.ok === 1) {
|
||||||
|
rec = await mytable.findById(mytablerec._id).lean();
|
||||||
|
} else {
|
||||||
|
rec = risult;
|
||||||
|
}
|
||||||
|
|
||||||
if (shared_consts.TABLES_GETCOMPLETEREC.includes(params.table)) {
|
if (shared_consts.TABLES_GETCOMPLETEREC.includes(params.table)) {
|
||||||
return await mytablestrutt.getCompleteRecord(rec.idapp, rec._id);
|
return await mytablestrutt.getCompleteRecord(rec.idapp, rec._id);
|
||||||
@@ -881,13 +901,13 @@ router.patch('/chval', authenticate, async (req, res) => {
|
|||||||
let valprec = 0
|
let valprec = 0
|
||||||
|
|
||||||
if ('saldo' in fieldsvalue) {
|
if ('saldo' in fieldsvalue) {
|
||||||
valprec = precRec && precRec.saldo ? precRec.saldo : 0
|
valprec = precRec && precRec.saldo ? precRec.saldo : 0
|
||||||
msg = i18n.__('SALDO_VARIATO', circuit.name, req.user.username, dest, valprec, fieldsvalue.saldo, circuit.symbol);
|
msg = i18n.__('SALDO_VARIATO', circuit.name, req.user.username, dest, valprec, fieldsvalue.saldo, circuit.symbol);
|
||||||
} else if ('fidoConcesso' in fieldsvalue) {
|
} else if ('fidoConcesso' in fieldsvalue) {
|
||||||
valprec = precRec && precRec.fidoConcesso ? precRec.fidoConcesso : 0
|
valprec = precRec && precRec.fidoConcesso ? precRec.fidoConcesso : 0
|
||||||
msg = i18n.__('FIDOCONCESSO_VARIATO', circuit.name, req.user.username, dest, valprec, fieldsvalue.fidoConcesso, circuit.symbol);
|
msg = i18n.__('FIDOCONCESSO_VARIATO', circuit.name, req.user.username, dest, valprec, fieldsvalue.fidoConcesso, circuit.symbol);
|
||||||
} else if ('qta_maxConcessa' in fieldsvalue) {
|
} else if ('qta_maxConcessa' in fieldsvalue) {
|
||||||
valprec = precRec && precRec.qta_maxConcessa ? precRec.qta_maxConcessa : 0
|
valprec = precRec && precRec.qta_maxConcessa ? precRec.qta_maxConcessa : 0
|
||||||
msg = i18n.__('QTAMAX_VARIATO', circuit.name, req.user.username, dest, valprec, fieldsvalue.qta_maxConcessa, circuit.symbol);
|
msg = i18n.__('QTAMAX_VARIATO', circuit.name, req.user.username, dest, valprec, fieldsvalue.qta_maxConcessa, circuit.symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user