forked from apxtri/apxtri
fix bug case 0 jobstepposition in post
This commit is contained in:
parent
2ba6787673
commit
053b45c81c
@ -524,10 +524,11 @@ Odmdb.accessright = (apxaccessrights, role, properties) => {
|
|||||||
//if (log) console.log(currentmod,"properties",properties)
|
//if (log) console.log(currentmod,"properties",properties)
|
||||||
const accessright = {};
|
const accessright = {};
|
||||||
console.log();
|
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) => {
|
||||||
if (apxaccessrights[p][act].length===0) apxaccessrights[p][act]=properties;
|
if (apxaccessrights[p][act].length === 0)
|
||||||
|
apxaccessrights[p][act] = properties;
|
||||||
if (!accessright[act]) {
|
if (!accessright[act]) {
|
||||||
accessright[act] = apxaccessrights[p][act];
|
accessright[act] = apxaccessrights[p][act];
|
||||||
} else {
|
} else {
|
||||||
@ -535,7 +536,7 @@ Odmdb.accessright = (apxaccessrights, role, properties) => {
|
|||||||
...new Set([...accessright[act], ...apxaccessrights[p][act]]),
|
...new Set([...accessright[act], ...apxaccessrights[p][act]]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return accessright;
|
return accessright;
|
||||||
@ -622,9 +623,10 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
|||||||
role,
|
role,
|
||||||
Object.keys(getschema.data.schema.properties)
|
Object.keys(getschema.data.schema.properties)
|
||||||
);
|
);
|
||||||
Object.keys(accessright).forEach(act=>{
|
Object.keys(accessright).forEach((act) => {
|
||||||
if (accessright[act].length===0) accessright[act]=Object.keys(getschema.data.schema.properties)
|
if (accessright[act].length === 0)
|
||||||
})
|
accessright[act] = Object.keys(getschema.data.schema.properties);
|
||||||
|
});
|
||||||
if (log) console.log(currentmod, "Accessright to: ", accessright);
|
if (log) console.log(currentmod, "Accessright to: ", accessright);
|
||||||
if (
|
if (
|
||||||
(crud == "C" && !accessright.C) ||
|
(crud == "C" && !accessright.C) ||
|
||||||
@ -652,7 +654,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// if Create Update erase old version
|
// if Create Update erase old version
|
||||||
let itmtostore={};
|
let itmtostore = {};
|
||||||
if (crud == "U" && accessright.U.length > 0) {
|
if (crud == "U" && accessright.U.length > 0) {
|
||||||
itmtostore = itmold;
|
itmtostore = itmold;
|
||||||
const keynotallow = Object.keys(itm).filter(
|
const keynotallow = Object.keys(itm).filter(
|
||||||
@ -666,23 +668,33 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
|||||||
//console.log(accessright)
|
//console.log(accessright)
|
||||||
accessright.U.forEach(async (p) => {
|
accessright.U.forEach(async (p) => {
|
||||||
// check this propertie exist in the requested update itm
|
// 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();
|
itmtostore.dt_update = dayjs().toISOString();
|
||||||
}
|
}
|
||||||
if (crud == "C"){
|
if (crud == "C") {
|
||||||
const keynotallow = Object.keys(itm).filter(
|
const keynotallow = Object.keys(itm).filter(
|
||||||
(el) => !accessright.C.includes(el)
|
(el) => !accessright.C.includes(el)
|
||||||
);
|
);
|
||||||
accessright.C.forEach(async (p) => {
|
accessright.C.forEach(async (p) => {
|
||||||
// check this propertie exist in the requested update itm
|
// 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();
|
itmtostore.dt_create = dayjs().toISOString();
|
||||||
}
|
}
|
||||||
Object.keys(itmtostore).forEach((k) => {
|
Object.keys(itmtostore).forEach((k) => {
|
||||||
// remove empty itmtostore in case they are =>
|
// 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];
|
if (itmtostore[k] === "") delete itmtostore[k];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user