This commit is contained in:
2019-04-24 23:05:43 +00:00
parent ae62da7697
commit 8cc2be7622
2 changed files with 115 additions and 24 deletions

View File

@@ -1,6 +1,30 @@
/* eslint-disable */
import _ from "../libs/lodash.min.js";
import store from "../store";
import ayatype from "./ayatype";
export default {
AYATYPE: {
NoType: 0,
Global: 1,
Widget: 2,
User: 3,
ServerState: 4,
License: 5,
LogFile: 6,
DEPRECATED_REUSELATER_7: 7,
DEPRECATED_REUSELATER_8: 8,
JobOperations: 9,
AyaNova7Import: 10,
TrialSeeder: 11,
Metrics: 12,
Locale: 13,
UserOptions: 14,
DEPRECATED_REUSELATER_15: 15,
DEPRECATED_REUSELATER_16: 16,
FileAttachment: 17,
DataFilter: 18,
FormCustom: 19
},
AUTHORIZATION_ROLES: {
///<summary>No role set</summary>
NoRole: 0,
@@ -41,7 +65,7 @@ export default {
}
return role === (store.state.roles & role);
},
rights(objType, objId) {
rights(userRole, oType, oId) {
//NOTE: this is to mirror the functionality of BizRoles.cs where all rights by role are specified in server project
//any change there needs to be mirrored here
@@ -60,31 +84,92 @@ export default {
readFull: false,
delete: false
};
// var AYANOVA_RIGHTS = JSON.parse(
// '{"User":{"Change":2,"EditOwn":0,"ReadFullRecord":1},"UserOptions":{"Change":2,"EditOwn":0,"ReadFullRecord":1},"Widget":{"Change":34,"EditOwn":256,"ReadFullRecord":17},"ServerState":{"Change":16384,"EditOwn":0,"ReadFullRecord":32767},"License":{"Change":16386,"EditOwn":0,"ReadFullRecord":8193},"LogFile":{"Change":0,"EditOwn":0,"ReadFullRecord":24576},"JobOperations":{"Change":16384,"EditOwn":0,"ReadFullRecord":8195},"AyaNova7Import":{"Change":16384,"EditOwn":0,"ReadFullRecord":0},"Metrics":{"Change":0,"EditOwn":0,"ReadFullRecord":24576},"Locale":{"Change":16386,"EditOwn":0,"ReadFullRecord":32767},"DataFilter":{"Change":2,"EditOwn":32767,"ReadFullRecord":32767},"FormCustom":{"Change":2,"EditOwn":0,"ReadFullRecord":32767}}'
// );
var typeName = _.findKey(this.AYATYPE, function(o) {
return o == oType;
});
switch (objType) {
case ayatype.Widget:
//WIDGET
// Change = AuthorizationRoles.BizAdminFull | AuthorizationRoles.InventoryFull,
// EditOwn = AuthorizationRoles.TechFull,
// ReadFullRecord = AuthorizationRoles.BizAdminLimited | AuthorizationRoles.InventoryLimited
ret.change =
this.hasrole(this.AUTHORIZATION_ROLES.BizAdminFull) ||
this.hasrole(this.AUTHORIZATION_ROLES.InventoryFull);
ret.editOwn =
objId == store.state.userId &&
this.hasrole(this.AUTHORIZATION_ROLES.TechFull);
ret.readFull =
this.hasrole(this.AUTHORIZATION_ROLES.BizAdminLimited) ||
this.hasRole(this.AUTHORIZATION_ROLES.InventoryLimited);
ret.delete = ret.change || ret.editOwn;
// var theType = _.find(this.AYATYPE, function(o) {
// return o.value == oType;
// });
// ////////////////////////////////////////////////////////////
var temp = typeName;
break;
default:
throw new "authorizationroles::rights - not coded for object type "() +
objType;
}
/**
*
* What to do:
* Object is to return ret fully set as per rights
*
* Look up AyaType key name from value (i.e. 2="Widget")
* Use the type key name to find the object in AYANOVA_RIGHTS by key name
* Error if not found of course
* Using the object found check if can do each thing in RET and return RET
*
* To check need to do just like HasRole, i.e. this: role === (store.state.roles & role);
*
* AyaNova7Import: Object { Change: 16384, EditOwn: 0, ReadFullRecord: 0 }
DataFilter: Object { Change: 2, EditOwn: 32767, ReadFullRecord: 32767 }
FormCustom: Object { Change: 2, EditOwn: 0, ReadFullRecord: 32767 }
JobOperations: Object { Change: 16384, EditOwn: 0, ReadFullRecord: 8195 }
License: Object { Change: 16386, EditOwn: 0, ReadFullRecord: 8193 }
Locale: Object { Change: 16386, EditOwn: 0, ReadFullRecord: 32767 }
LogFile: Object { Change: 0, EditOwn: 0, ReadFullRecord: 24576 }
Metrics: Object { Change: 0, EditOwn: 0, ReadFullRecord: 24576 }
ServerState: Object { Change: 16384, EditOwn: 0, ReadFullRecord: 32767 }
User: Object { Change: 2, EditOwn: 0, ReadFullRecord: 1 }
UserOptions: Object { Change: 2, EditOwn: 0, ReadFullRecord: 1 }
Widget: Object { Change: 34, EditOwn: 256, ReadFullRecord: 17 }
<prototype>: Object { … }
authorizationroles.js:72
userRole
"32767"
objType
2
*
*/
// switch (objType) {
// case ayatype.Widget:
// //WIDGET
// // Change = AuthorizationRoles.BizAdminFull | AuthorizationRoles.InventoryFull,
// // EditOwn = AuthorizationRoles.TechFull,
// // ReadFullRecord = AuthorizationRoles.BizAdminLimited | AuthorizationRoles.InventoryLimited
// ret.change =
// this.hasrole(this.AUTHORIZATION_ROLES.BizAdminFull) ||
// this.hasrole(this.AUTHORIZATION_ROLES.InventoryFull);
// ret.editOwn =
// objId == store.state.userId &&
// this.hasrole(this.AUTHORIZATION_ROLES.TechFull);
// ret.readFull =
// this.hasrole(this.AUTHORIZATION_ROLES.BizAdminLimited) ||
// this.hasRole(this.AUTHORIZATION_ROLES.InventoryLimited);
// ret.delete = ret.change || ret.editOwn;
// // ////////////////////////////////////////////////////////////
// break;
// default:
// throw new "authorizationroles::rights - not coded for object type "() +
// objType;
// }
return ret;
}
};
/*
{"User":{"Change":2,"EditOwn":0,"ReadFullRecord":1},"UserOptions":{"Change":2,"EditOwn":0,"ReadFullRecord":1},"Widget":{"Change":34,"EditOwn":256,"ReadFullRecord":17},"ServerState":{"Change":16384,"EditOwn":0,"ReadFullRecord":32767},"License":{"Change":16386,"EditOwn":0,"ReadFullRecord":8193},"LogFile":{"Change":0,"EditOwn":0,"ReadFullRecord":24576},"JobOperations":{"Change":16384,"EditOwn":0,"ReadFullRecord":8195},"AyaNova7Import":{"Change":16384,"EditOwn":0,"ReadFullRecord":0},"Metrics":{"Change":0,"EditOwn":0,"ReadFullRecord":24576},"Locale":{"Change":16386,"EditOwn":0,"ReadFullRecord":32767},"DataFilter":{"Change":2,"EditOwn":32767,"ReadFullRecord":32767},"FormCustom":{"Change":2,"EditOwn":0,"ReadFullRecord":32767}}
*/

View File

@@ -147,6 +147,7 @@
<script>
/* Xeslint-disable */
//import ayatype from "../api/ayatype";
function clickHandler(menuItem) {
if (!menuItem) {
@@ -370,6 +371,11 @@ export default {
alert("STUB: DELETE");
},
duplicate() {
this.$gzrole.rights(
this.$store.state.roles,
this.$gzrole.AYATYPE.Widget,
this.$store.state.userId
);
//only if not dirty
//check rights
//duplicate