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

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

parent bc851bac
No related branches found
No related tags found
No related merge requests found
import("Sql_lib");
import("system.tools");
import("system.vars");
import("system.result");
var childRoles = [];
var newChildRoles = [];
var alias = SqlUtils.getSystemAlias();
var parentRole = vars.get("$param.RoleId_param");
var allCustomAndProjectRoles = tools.getAllRoles(["CUSTOM", "PROJECT"], true);
var childRoles = newSelect("CHILD_ROLE", alias)
.from("ASYS_ROLES_CHILDREN")
.where("ASYS_ROLES_CHILDREN.PARENT_ROLE", parentRole)
.table();
for each (let role in allCustomAndProjectRoles) {
if (role[3] != parentRole) {
childRoles.push([role[3], role[3]]);
if (role[3] != parentRole) { // dont show same role as parent in dropdown
newChildRoles.push([role[3], role[3]]);
}
}
result.object(childRoles.sort());
\ No newline at end of file
result.object(newChildRoles.sort());
\ No newline at end of file
......@@ -9,15 +9,14 @@ var parentRoleName = vars.exists("$param.RoleId_param") && vars.get("$param.Role
var children = [];
if (parentRoleName && parentRoleName.indexOf("CUSTOM_") != -1) {
// parentRoleName is a viable CUSTOM role
var sqlStr = "select CHILD_ROLE, ID from ASYS_ROLES_CHILDREN where PARENT_ROLE = '" + parentRoleName + "'";
var childRoles = db.table(sqlStr, alias);
if (childRoles.length != 0) {
for each (let childRole in childRoles) {
children.push([childRole[1], childRole[0], parentRoleName]);
}
} else {
children.push(["", "", parentRoleName]);
// roles can only be assigned to CUSTOM roles -> parent role has to be a viable CUSTOM role
childRoles = newSelect("ID, CHILD_ROLE", alias)
.from("ASYS_ROLES_CHILDREN")
.where("ASYS_ROLES_CHILDREN.PARENT_ROLE", parentRoleName)
.table();
for each (let childRole in childRoles) {
children.push([childRole[0], childRole[1], parentRoleName]);
}
var ids = vars.get("$local.idvalues");
......
......@@ -9,7 +9,6 @@ var parentRoleName = vars.exists("$param.RoleId_param") && vars.get("$param.Role
if (parentRoleName && parentRoleName.indexOf("CUSTOM_") != -1) {
var alias = SqlUtils.getSystemAlias();
var childRole = vars.get("$local.rowdata")["CHILD_ROLE.value"];
var uid = util.getNewUUID();
var uid = vars.get("$field.UID")
db.insertData("ASYS_ROLES_CHILDREN", ["CHILD_ROLE", "PARENT_ROLE", "ID"], null, [childRole, parentRoleName, uid], alias);
}
\ 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