Skip to content
Snippets Groups Projects
Commit 3310f3c2 authored by Simon Leipold's avatar Simon Leipold
Browse files

Permissions - bug fix: no more action duplicates possible

parent 0a973800
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
<name>PermissionAction_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<title>Action</title>
<onValidation>%aditoprj%/entity/PermissionAction_entity/onValidation.js</onValidation>
<titlePlural>Actions</titlePlural>
<recordContainer>jDito</recordContainer>
<entityFields>
......
......@@ -25,71 +25,4 @@ switch (accesstype) {
]
}
result.object(actions);
//#############################################################################
//################only show actions which are not yet in the DB################
//##########################not done yet#######################################
//#############################################################################
//import("system.logging");
//import("Permission_lib");
//import("system.vars");
//import("system.result");
//
//var permisson = vars.get("$param.PermissionId_param");
//var actionIdsInDb = PermissionUtil.getPermissionAction(permisson);
//var actionsInDb = [];
//for each (var actionId in actionIdsInDb) {
// actionsInDb.push(PermissionUtil.resolvePermissionActionId(actionId));
//}
//
//var entityActions = ["view", "create"];
//var recordActions = ["read", "update", "delete"];
//var fieldActions = ["read", "update"];
//var diff;
//
//var accesstype = vars.get("$param.AccessType_param");
//var actions = [];
//
//switch (accesstype) {
// case "E":
// diff = arrDiff(actionsInDb, entityActions);
// break;
// case "R":
// diff = arrDiff(actionsInDb, recordActions);
// break;
// case "F":
// diff = arrDiff(actionsInDb, fieldActions);
// break;
//}
//
//for each (let entry in diff) {
// actions.push([entry, entry]);
//}
//
//result.object(actions);
//
//// arrDiff calculates different elements of two arrays and returns them as array, otherwise empty array
//function arrDiff (arr1, arr2) {
// var helperArr = [], diff = [];
//
// for (let i = 0; i < arr1.length; i++) {
// helperArr[arr1[i]] = true;
// }
//
// for (let i = 0; i < arr2.length; i++) {
// if (helperArr[arr2[i]]) {
// delete helperArr[arr2[i]];
// }
// else {
// helperArr[arr2[i]] = true;
// }
// }
//
// for (var k in helperArr) {
// diff.push(k);
// }
//
// return diff;
//}
\ No newline at end of file
result.object(actions);
\ No newline at end of file
import("system.vars");
import("system.translate");
import("system.result");
import("Permission_lib");
var permissionId = vars.get("$param.PermissionId_param");
var actionTitle = vars.get("$field.ACTION");
if (PermissionUtil.existsPermission(permissionId)) {
// existing permission
// check if action is already in DB
var actionsInDb = PermissionUtil.getPermissionAction(permissionId);
for each (var action in actionsInDb) {
if (PermissionUtil.resolvePermissionActionId(action) == actionTitle) {
result.string(translate.text("Action '" + actionTitle + "' already linked to this permission!"));
break;
}
}
}
\ No newline at end of file
import("system.logging");
import("system.db");
import("system.tools");
import("system.result");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment