From cbbd7760bbc8bb5d77a64913d779dcf311157cb7 Mon Sep 17 00:00:00 2001 From: philc Date: Tue, 10 Dec 2024 15:35:04 +0100 Subject: [PATCH] fix bug with propertie * --- README.md | 9 ++++++++- apxtri/models/Checkjson.js | 17 +++++++++-------- apxtri/models/Odmdb.js | 3 +-- apxtri/models/Wwws.js | 2 +- apxtri/routes/odmdb.js | 2 +- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 18f5065..3da7483 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,14 @@ Until the web interface allow it here are usefull process to: ``` cd .. && . setup.sh tribename newtribe ``` - This will create a new tribe that you can manage in http://admin.tribename.dev.ants (a standard .giitignore is generate ready if you want to version your code in apxtri) + This will create a new tribe that you can manage in http://admin.tribename.dev.ants (a standard .gitignore is generate ready if you want to version your code in apxtri) + +* create an empty tribe call tribename with a code from a git repo +``` + cd .. && . setup.sh okwo newtribe https://gitea.ndda.fr/ndda/okwo.git +``` + This will create a new tribe okwo without data http://admin.tribename.dev.ants (a standard .gitignore is generate ready if you want to version your code in apxtri) + * To add a new tribe from an existing tribe host in app1.smatchit.io, we want set a dev env from git repo named smatchit with data that come from admin.smatchit.io the last night. To get data you must have the access_code to access backup (request to admin of smatchit to replace 1234). ``` diff --git a/apxtri/models/Checkjson.js b/apxtri/models/Checkjson.js index fd5548b..4dcc3f9 100755 --- a/apxtri/models/Checkjson.js +++ b/apxtri/models/Checkjson.js @@ -191,7 +191,7 @@ Checkjson.schema.validation = (schema) => { * @param {*} data some data to check using schema * @param {*} withschemacheck boolean that force a schema check (usefull on modification schema) * @returns {status: 200, ref:"Checkjson", msg:"validcheck", data:{itm:object}} - * {status:417, multimsg:[{re,msg,data}],data:{itm:object}} + * {status:417, multimsg:[{re,msg,data}],data:{itm:object}} itm with only valid data */ Checkjson.schema.data = (schema, data, withschemacheck) => { /* validate a data set with a schema in a context ctx */ @@ -206,12 +206,14 @@ Checkjson.schema.data = (schema, data, withschemacheck) => { // subdata={prop1,prop2} // Return [] => no error, else 1 item per error {msg,ref:checkjson,data} const propertielist = Object.keys(properties); - console.log(propertielist); - Object.keys(subdata).forEach((kdata) => { - if (!propertielist.includes(kdata)) { - delete subdata[kdata]; - } - }); + if (!propertielist.includes("*")) { + // case properties is not any (*) then delete propertie + Object.keys(subdata).forEach((kdata) => { + if (!propertielist.includes(kdata)) { + delete subdata[kdata]; + } + }); + } let multimsg = []; propertielist.forEach((p) => { //type is mandatory in a propertie @@ -364,7 +366,6 @@ Checkjson.schema.data = (schema, data, withschemacheck) => { } let multi = propertiescheck(schema.properties, data); const res = {}; - if (multi.length > 0) { res.status = 417; res.multimsg = multi; diff --git a/apxtri/models/Odmdb.js b/apxtri/models/Odmdb.js index 80aad77..679503b 100644 --- a/apxtri/models/Odmdb.js +++ b/apxtri/models/Odmdb.js @@ -514,6 +514,7 @@ Odmdb.r = (objectPathname, apxid, role) => { * Convert profils in accessright * @param {*} apxaccessright from schema object {profilname:{R}} * @param {*} role {xprofils,xalias} accessible after isAuthenticated + * @param {*} properties array of properties in case accessright is set at [] it means we allow all properties of the schema * @returns access right to C create if present, to read (properties list or all if empty), to Update properties list or all if empty, D elete * example: {"C":[],"R":[properties list],"U":[properties ist],"D":[]} */ @@ -522,7 +523,6 @@ Odmdb.accessright = (apxaccessrights, role, properties) => { //if (log) console.log(currentmod,"role",role) //if (log) console.log(currentmod,"properties",properties) const accessright = {}; - console.log(); role.xprofils.forEach((p) => { if (apxaccessrights[p]) { Object.keys(apxaccessrights[p]).forEach((act) => { @@ -687,7 +687,6 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => { //console.log(k, itmtostore[k], itmtostore[k] === ""); if (itmtostore[k] === "") delete itmtostore[k]; }); - Object.keys(itmtostore).forEach((k) => { //Manage base64 case image to convert ans store in webp if (k.includes("imgbase64_") && itmtostore[k] != "") { diff --git a/apxtri/models/Wwws.js b/apxtri/models/Wwws.js index f7a857b..567788f 100644 --- a/apxtri/models/Wwws.js +++ b/apxtri/models/Wwws.js @@ -129,10 +129,10 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => { if (loc.tpl) { Object.keys(loc.tpl).forEach((r) => { let src = `../${loc.tpl[r]}`; - //console.log(path.resolve(src)) if (!fs.existsSync(src)) { src += `_${lg}.mustache`; } + //console.log(path.resolve(src)) if (fs.existsSync(src)) { localstorage.tpl[r] = fs.readFileSync(src,'utf-8'); } else { diff --git a/apxtri/routes/odmdb.js b/apxtri/routes/odmdb.js index 4ecd047..82e6f6a 100644 --- a/apxtri/routes/odmdb.js +++ b/apxtri/routes/odmdb.js @@ -599,7 +599,7 @@ router.get( "frenchlocation": { "title": "Location", "description": "use franch gov refential to locaize", - "$ref": "nationchains/schema/frenchlocation" + "$ref": "adminapi/schema/frenchlocation" }, "denomination": { "title": "Company name",