This commit is contained in:
2020-08-13 22:48:30 +00:00
parent 8b3596188a
commit 1aa13ec301
4 changed files with 32 additions and 77 deletions

View File

@@ -114,11 +114,22 @@ export default {
//get the logged in user's role
let userRole = window.$gz.store.state.roles;
// console.log("Authorization roles getRights, userRole=", userRole);
// console.log(
// `Authorization roles getRights for ${typeName} objectRoleRights=`,
// objectRoleRights
// );
//calculate the effective rights
//a non zero result of the bitwise calculation means true and zero means false so using !! to force it into a boolean value
//(contrary to some style guides that say !! is obscure but I say it saves a lot of typing)
let canChange = !!(userRole & objectRoleRights.Change);
let canReadFullRecord = !!(userRole & objectRoleRights.ReadFullRecord);
//sometimes rights to read are false if change is true since change trumps read anyway so accordingly:
let canReadFullRecord = canChange;
if (!canReadFullRecord) {
//can't change but might have special rights to full record:
canReadFullRecord = !!(userRole & objectRoleRights.ReadFullRecord);
}
ret.change = canChange;
ret.delete = ret.change; //FOR NOW
@@ -132,6 +143,10 @@ export default {
//
canOpen(oType) {
let r = this.getRights(oType);
// //Am seeing where change is true but read is false, change trumps read so ...
// if (r.change == true) {
// return true;
// }
return r.read;
}
};