From 38587df7e94170de355d7853912d7c652c02d967 Mon Sep 17 00:00:00 2001 From: philc Date: Thu, 27 Mar 2025 12:14:59 +0100 Subject: [PATCH] fix boolean update odmdb --- apxtri/models/Notifications.js | 5 ++--- apxtri/models/Odmdb.js | 17 +++++++++++++++-- apxtri/routes/articles.js | 2 +- package.json | 8 ++++---- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/apxtri/models/Notifications.js b/apxtri/models/Notifications.js index 54672eb..b1a3b07 100644 --- a/apxtri/models/Notifications.js +++ b/apxtri/models/Notifications.js @@ -297,9 +297,8 @@ Notifications.manageemail = async ( } emailtosend.to = ""; email.to.forEach((em) => { - em = em.toLowerCase().trim(); - if (Checkjson.testformat(em, "email")) { - emailtosend.to += em + ","; + if (typeof em === "string" && Checkjson.testformat(em, "email")) { + emailtosend.to += em.toLowerCase().trim() + ","; } else { results.fail.push({ to: em, err: ["errorformat"] }); } diff --git a/apxtri/models/Odmdb.js b/apxtri/models/Odmdb.js index a6d8d26..03d2d93 100644 --- a/apxtri/models/Odmdb.js +++ b/apxtri/models/Odmdb.js @@ -656,14 +656,27 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => { //console.log('itmstore',itmtostore) //console.log("itm",itm) //console.log(accessright) - accessright.U.forEach(async (p) => { + /*accessright.U.forEach(async (p) => { // check this propertie exist in the requested update itm const testvaliditmupdate = - itm[p] === 0 || + itm[p] === 0 || itm[p] === true || itm[p]=== false || (itm[p] && ((typeof itm[p] === "string" && itm[p].trim() !== "") || typeof itm[p] !== "string")); if (testvaliditmupdate) itmtostore[p] = itm[p]; + });*/ + accessright.U.forEach(async (p) => { + if (itm[p] === 0 || itm[p] === false || itm[p] === true) { + // Cas numéro 0 ou booléens + itmtostore[p] = itm[p]; + } else if (itm[p]) { + // Cas non-vide (autres types) + if (typeof itm[p] === "string") { + if (itm[p].trim() !== "") itmtostore[p] = itm[p]; // String non vide + } else { + itmtostore[p] = itm[p]; // Autres types (objets, nombres, etc.) + } + } }); itmtostore.dt_update = dayjs().toISOString(); } diff --git a/apxtri/routes/articles.js b/apxtri/routes/articles.js index 2f71cef..8a4e884 100644 --- a/apxtri/routes/articles.js +++ b/apxtri/routes/articles.js @@ -9,7 +9,7 @@ const Articles = require(`../models/Articles`); const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`); const currentmod = "Articles"; -const log = conftrib.activelog.includes(currentmod); +const log = conf.api.activelog.includes(currentmod); const router = express.Router(); diff --git a/package.json b/package.json index b036137..53ca6b0 100755 --- a/package.json +++ b/package.json @@ -54,11 +54,13 @@ }, "license": "MIT", "dependencies": { + "@tailwindcss/typography": "^0.5.15", "apidoc": "^1.2.0", "async": "^3.2.0", "axios": "^1.7.8", "bcrypt": "^5.0.0", "cors": "^2.8.4", + "daisyui": "^5.0.9", "dayjs": "^1.11.13", "dns-sync": "^0.2.1", "express": "^4.21.1", @@ -78,10 +80,8 @@ "sharp": "^0.33.5", "smtp-client": "^0.4.0", "stripe": "^17.3.1", - "uuid": "^11.0.2", - "@tailwindcss/typography": "^0.5.15", - "daisyui": "^4.12.23", - "tailwindcss": "^3.4.17" + "tailwindcss": "^4.0.15", + "uuid": "^11.0.2" }, "devDependencies": {} }