1
0
forked from apxtri/apxtri

fix bug case 0 jobstepposition in post

This commit is contained in:
philc 2024-10-02 17:29:20 +02:00
parent 2ba6787673
commit 053b45c81c

View File

@ -524,19 +524,20 @@ Odmdb.accessright = (apxaccessrights, role, properties) => {
//if (log) console.log(currentmod,"properties",properties)
const accessright = {};
console.log();
role.xprofils.forEach(p => {
role.xprofils.forEach((p) => {
if (apxaccessrights[p]) {
Object.keys(apxaccessrights[p]).forEach(act => {
if (apxaccessrights[p][act].length===0) apxaccessrights[p][act]=properties;
Object.keys(apxaccessrights[p]).forEach((act) => {
if (apxaccessrights[p][act].length === 0)
apxaccessrights[p][act] = properties;
if (!accessright[act]) {
accessright[act] = apxaccessrights[p][act];
} else {
accessright[act] = [
...new Set([...accessright[act], ...apxaccessrights[p][act]]),
];
accessright[act] = [
...new Set([...accessright[act], ...apxaccessrights[p][act]]),
];
}
})
}
});
}
});
return accessright;
};
@ -622,9 +623,10 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
role,
Object.keys(getschema.data.schema.properties)
);
Object.keys(accessright).forEach(act=>{
if (accessright[act].length===0) accessright[act]=Object.keys(getschema.data.schema.properties)
})
Object.keys(accessright).forEach((act) => {
if (accessright[act].length === 0)
accessright[act] = Object.keys(getschema.data.schema.properties);
});
if (log) console.log(currentmod, "Accessright to: ", accessright);
if (
(crud == "C" && !accessright.C) ||
@ -652,7 +654,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
);
} else {
// if Create Update erase old version
let itmtostore={};
let itmtostore = {};
if (crud == "U" && accessright.U.length > 0) {
itmtostore = itmold;
const keynotallow = Object.keys(itm).filter(
@ -666,23 +668,33 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
//console.log(accessright)
accessright.U.forEach(async (p) => {
// check this propertie exist in the requested update itm
if (itm[p] && itm[p] !== "") itmtostore[p] = itm[p];
const testvaliditmupdate =
itm[p] === 0 ||
(itm[p] &&
((typeof itm[p] === "string" && itm[p].trim() !== "") ||
typeof itm[p] !== "string"));
if (testvaliditmupdate) itmtostore[p] = itm[p];
});
itmtostore.dt_update = dayjs().toISOString();
}
if (crud == "C"){
if (crud == "C") {
const keynotallow = Object.keys(itm).filter(
(el) => !accessright.C.includes(el)
);
accessright.C.forEach(async (p) => {
// check this propertie exist in the requested update itm
if (itm[p] && itm[p] !== "") itmtostore[p] = itm[p];
const testvaliditmcreate =
itm[p] === 0 ||
(itm[p] &&
((typeof itm[p] === "string" && itm[p].trim() !== "") ||
typeof itm[p] !== "string"));
if (testvaliditmcreate) itmtostore[p] = itm[p];
});
itmtostore.dt_create = dayjs().toISOString();
}
Object.keys(itmtostore).forEach((k) => {
// remove empty itmtostore in case they are =>
console.log(k, itmtostore[k], itmtostore[k] === "");
//console.log(k, itmtostore[k], itmtostore[k] === "");
if (itmtostore[k] === "") delete itmtostore[k];
});