fix bug with propertie *

This commit is contained in:
philc 2024-12-10 15:35:04 +01:00
parent b787ebd945
commit cbbd7760bb
5 changed files with 20 additions and 13 deletions

View File

@ -93,7 +93,14 @@ Until the web interface allow it here are usefull process to:
``` ```
cd .. && . setup.sh tribename newtribe 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). * 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).
``` ```

View File

@ -191,7 +191,7 @@ Checkjson.schema.validation = (schema) => {
* @param {*} data some data to check using schema * @param {*} data some data to check using schema
* @param {*} withschemacheck boolean that force a schema check (usefull on modification schema) * @param {*} withschemacheck boolean that force a schema check (usefull on modification schema)
* @returns {status: 200, ref:"Checkjson", msg:"validcheck", data:{itm:object}} * @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) => { Checkjson.schema.data = (schema, data, withschemacheck) => {
/* validate a data set with a schema in a context ctx */ /* validate a data set with a schema in a context ctx */
@ -206,12 +206,14 @@ Checkjson.schema.data = (schema, data, withschemacheck) => {
// subdata={prop1,prop2} // subdata={prop1,prop2}
// Return [] => no error, else 1 item per error {msg,ref:checkjson,data} // Return [] => no error, else 1 item per error {msg,ref:checkjson,data}
const propertielist = Object.keys(properties); const propertielist = Object.keys(properties);
console.log(propertielist); if (!propertielist.includes("*")) {
Object.keys(subdata).forEach((kdata) => { // case properties is not any (*) then delete propertie
if (!propertielist.includes(kdata)) { Object.keys(subdata).forEach((kdata) => {
delete subdata[kdata]; if (!propertielist.includes(kdata)) {
} delete subdata[kdata];
}); }
});
}
let multimsg = []; let multimsg = [];
propertielist.forEach((p) => { propertielist.forEach((p) => {
//type is mandatory in a propertie //type is mandatory in a propertie
@ -364,7 +366,6 @@ Checkjson.schema.data = (schema, data, withschemacheck) => {
} }
let multi = propertiescheck(schema.properties, data); let multi = propertiescheck(schema.properties, data);
const res = {}; const res = {};
if (multi.length > 0) { if (multi.length > 0) {
res.status = 417; res.status = 417;
res.multimsg = multi; res.multimsg = multi;

View File

@ -514,6 +514,7 @@ Odmdb.r = (objectPathname, apxid, role) => {
* Convert profils in accessright * Convert profils in accessright
* @param {*} apxaccessright from schema object {profilname:{R}} * @param {*} apxaccessright from schema object {profilname:{R}}
* @param {*} role {xprofils,xalias} accessible after isAuthenticated * @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 * @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":[]} * 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,"role",role)
//if (log) console.log(currentmod,"properties",properties) //if (log) console.log(currentmod,"properties",properties)
const accessright = {}; const accessright = {};
console.log();
role.xprofils.forEach((p) => { role.xprofils.forEach((p) => {
if (apxaccessrights[p]) { if (apxaccessrights[p]) {
Object.keys(apxaccessrights[p]).forEach((act) => { 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] === ""); //console.log(k, itmtostore[k], itmtostore[k] === "");
if (itmtostore[k] === "") delete itmtostore[k]; if (itmtostore[k] === "") delete itmtostore[k];
}); });
Object.keys(itmtostore).forEach((k) => { Object.keys(itmtostore).forEach((k) => {
//Manage base64 case image to convert ans store in webp //Manage base64 case image to convert ans store in webp
if (k.includes("imgbase64_") && itmtostore[k] != "") { if (k.includes("imgbase64_") && itmtostore[k] != "") {

View File

@ -129,10 +129,10 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
if (loc.tpl) { if (loc.tpl) {
Object.keys(loc.tpl).forEach((r) => { Object.keys(loc.tpl).forEach((r) => {
let src = `../${loc.tpl[r]}`; let src = `../${loc.tpl[r]}`;
//console.log(path.resolve(src))
if (!fs.existsSync(src)) { if (!fs.existsSync(src)) {
src += `_${lg}.mustache`; src += `_${lg}.mustache`;
} }
//console.log(path.resolve(src))
if (fs.existsSync(src)) { if (fs.existsSync(src)) {
localstorage.tpl[r] = fs.readFileSync(src,'utf-8'); localstorage.tpl[r] = fs.readFileSync(src,'utf-8');
} else { } else {

View File

@ -599,7 +599,7 @@ router.get(
"frenchlocation": { "frenchlocation": {
"title": "Location", "title": "Location",
"description": "use franch gov refential to locaize", "description": "use franch gov refential to locaize",
"$ref": "nationchains/schema/frenchlocation" "$ref": "adminapi/schema/frenchlocation"
}, },
"denomination": { "denomination": {
"title": "Company name", "title": "Company name",