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

Permissions - bug fix - sorting takes condition into account now

parent cf5749d1
No related branches found
No related tags found
No related merge requests found
......@@ -106,7 +106,8 @@ if (selectedPermission == null) {
}
}
result.object(res.sort(sortResultsByCondition).sort(sortResultsByAccessTypes));
res = res.sort(sortResultsByCondition).sort(sortResultsByAccessTypes);
result.object(res);
function prepareResultArray(pEntry, pRes) {
var parentPermission = "";
......@@ -163,7 +164,10 @@ function sortActions(actions, accesstype) {
// sorts result array: Entity -> Records -> Fields
function sortResultsByAccessTypes(a, b) {
if (a[6] == b[6] && a[6] != "F" && a[6] != "R")
var noCondA = "{\"entity\":\"" + a[1] + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
var noCondB = "{\"entity\":\"" + b[1] + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
if (a[6] == b[6] && a[6] == "E")
return 0;
else if (a[6] == "E")
return -1;
......@@ -173,28 +177,26 @@ function sortResultsByAccessTypes(a, b) {
return -1;
else if (a[6] == "F" && b[6] == "R")
return 1;
else if (a[6] == "R" && b[6] == "R" && a[4] == "")
return -1;
else if (a[6] == "R" && b[6] == "R" && b[4] == "")
return 1;
else if (a[6] == "F" && b[6] == "F" && a[4] == "")
else if (a[6] == b[6] && (a[4] == "" || a[4] == noCondA))
return -1;
else if (a[6] == "F" && b[6] == "F" && b[4] == "")
else if (a[6] == b[6] && (b[4] == "" || b[4] == noCondB))
return 1;
else
else
return 0;
}
// sorts result array: default permission -> conditional permission
function sortResultsByCondition(a, b) {
var noCond = "{\"entity\":\"" + vars.get("$field.ENTITY") + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
var noCondA = "{\"entity\":\"" + a[1] + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
var noCondB = "{\"entity\":\"" + b[1] + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
if (a[4] == "" || a[4] == noCond) {
return -1;
} else if (b[4] == "" || b[4] == noCond) {
} else if (b[4] == "" || b[4] == noCondB) {
return -1;
} else if (a[4] != "" && a[4] != noCond) {
} else if (a[4] != "" && a[4] != noCondA) {
return 1;
} else if (b[4] != "" && b[4] != noCond) {
} else if (b[4] != "" && b[4] != noCondB) {
return 1;
} else {
return 0;
......
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