From 38721782f82f49f5321895b8d181dcd63ae29102 Mon Sep 17 00:00:00 2001 From: Simon Leipold <s.leipold@adito.de> Date: Wed, 5 Feb 2020 17:01:00 +0100 Subject: [PATCH] [Projekt: Entwicklung - Neon][TicketNr.: 1049945][Rollen - Fehler bei Zuweisung von Kindrollen] --- .../entityfields/child_role/dropDownProcess.js | 14 ++++++++++---- .../recordcontainers/jdito/contentProcess.js | 17 ++++++++--------- .../recordcontainers/jdito/onInsert.js | 3 +-- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/entity/RoleChildren_entity/entityfields/child_role/dropDownProcess.js b/entity/RoleChildren_entity/entityfields/child_role/dropDownProcess.js index 9d8e51b74c..34affa61dc 100644 --- a/entity/RoleChildren_entity/entityfields/child_role/dropDownProcess.js +++ b/entity/RoleChildren_entity/entityfields/child_role/dropDownProcess.js @@ -1,15 +1,21 @@ +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 diff --git a/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js b/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js index cf0d3c41b7..f21fb44def 100644 --- a/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js @@ -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"); diff --git a/entity/RoleChildren_entity/recordcontainers/jdito/onInsert.js b/entity/RoleChildren_entity/recordcontainers/jdito/onInsert.js index 7fec6ad58d..60f0bfa215 100644 --- a/entity/RoleChildren_entity/recordcontainers/jdito/onInsert.js +++ b/entity/RoleChildren_entity/recordcontainers/jdito/onInsert.js @@ -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 -- GitLab