- aggiornati gli argomenti in base a GM

This commit is contained in:
Surya Paolo
2025-02-12 18:31:59 +01:00
parent b643c7cdc3
commit d77f9381e5
8 changed files with 202 additions and 60 deletions

View File

@@ -357,6 +357,7 @@ router.post('/settable', authenticate, async (req, res) => {
if ((!User.isAdmin(req.user.perm)
&& !User.isManager(req.user.perm)
&& !User.isEditor(req.user.perm)
&& !User.isGrafico(req.user.perm)
&& !User.isFacilitatore(req.user.perm))
&&
await !tools.ModificheConsentite(req, params.table, fieldsvalue, mydata ? mydata._id : '')) {
@@ -412,12 +413,18 @@ router.post('/settable', authenticate, async (req, res) => {
delete mydata['__v'];
delete mydata['__proto__'];
let mytablerec = new mytable(mydata);
const isNotNew = (mydata['_id'] !== undefined && mydata['_id'] !== 0 && mydata['_id'] !== '');
let mytablerec = null;
mytablerec = new mytable(mydata);
// console.log('mytablerec', mytablerec);
const mytablestrutt = globalTables.getTableByTableName(params.table);
if (mydata['_id'] !== undefined && mydata['_id'] !== 0 && mydata['_id'] !== '') {
if (isNotNew) {
mytablerec.isNew = false;
}
@@ -427,7 +434,9 @@ router.post('/settable', authenticate, async (req, res) => {
} else if (params.table === 'hours') {
} else {
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined || mytablerec._id === '0')) {
if ((mydata['_id'] === undefined || mydata['_id'] === '' ||
(mytablerec.isNew && mydata['_id'] === 0))
&& (mytablerec._id === undefined || mytablerec._id === '0')) {
mytablerec._id = new ObjectId();
mydata._id = new ObjectId();
mytablerec.isNew = true;
@@ -493,6 +502,11 @@ router.post('/settable', authenticate, async (req, res) => {
return await myPromise
.then(async (doupdate) => {
if (false) {
let plainObject = mytablerec.toObject();
console.log(plainObject);
}
if (doupdate)
return mytable.updateOne({ _id: mytablerec._id }, mydata, { new: true })
else
@@ -673,7 +687,7 @@ router.post('/getobj', authenticate_noerror, async (req, res) => {
try {
let cmd = req.body.cmd;
let idapp = req.user ? req.user.idapp : sanitizeHtml(req.body.idapp); // Cambiato from params.idapp a req.body.idapp
let ris = null;
let ris = null;
if (cmd === 'lista_editori') {
ris = await User.find(