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

[Projekt: Entwicklung - Neon][TicketNr.: 1049945][Rollen - Fehler bei Zuweisung von Kindrollen]

parent b741d1c8
No related branches found
No related tags found
No related merge requests found
...@@ -7,15 +7,32 @@ var newChildRoles = []; ...@@ -7,15 +7,32 @@ var newChildRoles = [];
var alias = SqlUtils.getSystemAlias(); var alias = SqlUtils.getSystemAlias();
var parentRole = vars.get("$param.RoleId_param"); var parentRole = vars.get("$param.RoleId_param");
var allCustomAndProjectRoles = tools.getAllRoles(["CUSTOM", "PROJECT"], true); var allCustomAndProjectRoles = tools.getAllRoles(["CUSTOM", "PROJECT"], true);
var childRoles = newSelect("CHILD_ROLE", alias) var childRoles = newSelect("CHILD_ROLE", alias)
.from("ASYS_ROLES_CHILDREN") .from("ASYS_ROLES_CHILDREN")
.where("ASYS_ROLES_CHILDREN.PARENT_ROLE", parentRole) .where("ASYS_ROLES_CHILDREN.PARENT_ROLE", parentRole)
.table(); .table();
var parentIsAlreadyChildOf = newSelect("PARENT_ROLE", alias)
.from("ASYS_ROLES_CHILDREN")
.where("ASYS_ROLES_CHILDREN.CHILD_ROLE", parentRole)
.table();
for each (let role in allCustomAndProjectRoles) { for each (let role in allCustomAndProjectRoles) {
if (role[3] != parentRole) { // dont show same role as parent in dropdown // dont show current role as possible child in dropdown
if (role[3] != parentRole) {
newChildRoles.push([role[3], role[3]]); newChildRoles.push([role[3], role[3]]);
} }
} }
// check for cyclces in hierarchy, A can't be child of B while it is already parent of B
for each (let role in parentIsAlreadyChildOf) {
newChildRoles = newChildRoles.filter(function(childRole) {
if (role == childRole[0]) {
return false;
}
return true;
});
}
result.object(newChildRoles.sort()); result.object(newChildRoles.sort());
\ No newline at end of file
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