This commit is contained in:
2019-06-05 00:02:53 +00:00
parent 9427fd1a8a
commit f4d9220d62
9 changed files with 195 additions and 88 deletions

View File

@@ -1,9 +1,9 @@
/* eslint-disable */
/* xeslint-disable */
import _ from "../libs/lodash.min.js";
import store from "../store";
import rights from "./bizroles";
export default {
export default {
ROLE_RIGHTS: rights,
AUTHORIZATION_ROLES: {
///<summary>No role set</summary>
@@ -48,8 +48,7 @@ export default {
/////////////////////////////////
//
//
getRights(vm, oType) {
getRights(vm, oType) {
//from bizroles.cs:
//HOW THIS WORKS / WHATS EXPECTED
//Change = CREATE, RETRIEVE, UPDATE, DELETE - Full rights
@@ -72,24 +71,23 @@ export default {
//Get the AyaNova stock role rights for that object
var objectRoleRights = this.ROLE_RIGHTS[typeName];
//get the logged in user's role
var userRole = vm.$store.state.roles;
//calculate the effective rights
//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)
var canChange = !!(userRole & objectRoleRights.Change);
var canChange = !!(userRole & objectRoleRights.Change);
var canReadFullRecord = !!(userRole & objectRoleRights.ReadFullRecord);
ret.change=canChange;
ret.delete=ret.change;//FOR NOW
ret.read=canReadFullRecord;
ret.change = canChange;
ret.delete = ret.change; //FOR NOW
ret.read = canReadFullRecord;
return ret;
}
};
/*
/*
USING BITWISE OPERATORS CHEAT SHEET
//https://codeburst.io/using-javascript-bitwise-operators-in-real-life-f551a731ff5
// Test whether your bit number has a single attribute. '&' ensures
@@ -127,4 +125,4 @@ if (myBitNumber == (myBitNumber | (HAS_FOO2 | HAS_FOO4))) {
if (myBitNumber == (myBitNumber | (HAS_FOO2 | HAS_FOO3 | HAS_FOO4))) {
// False
}
*/
*/