From 4d87213f6ac8870c4390fd0992415aefe72425a2 Mon Sep 17 00:00:00 2001
From: Simon Leipold <s.leipold@adito.de>
Date: Wed, 26 May 2021 16:25:45 +0200
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?=
 =?UTF-8?q?=201081447][Mitarbeiterrolle=20bearbeiten=20funktioniert,=20erz?=
 =?UTF-8?q?eugt=20aber=20Fehler=20an=20der=20Oberfl=C3=A4che]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../recordcontainers/jdito/contentProcess.js        | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/entity/EmployeeRole_entity/recordcontainers/jdito/contentProcess.js b/entity/EmployeeRole_entity/recordcontainers/jdito/contentProcess.js
index dd75cc33f8..84cbd8aec7 100644
--- a/entity/EmployeeRole_entity/recordcontainers/jdito/contentProcess.js
+++ b/entity/EmployeeRole_entity/recordcontainers/jdito/contentProcess.js
@@ -31,7 +31,18 @@ if (userTitle && tools.existUsers(userTitle))
 }
 
 var idvalues = vars.get("$local.idvalues");
-if (!Utils.isNullOrEmpty(idvalues))
+var selectedRole = vars.get("$field.ROLE");
+
+// if idvalues and selectedRole are filled -> insert, update or delete happened
+// if idvalues and selectedRole are filled and distinct -> edit (role in idvalues got changed to role in selectedRole)
+if (!Utils.isNullOrEmpty(idvalues) && !Utils.isNullOrEmpty(selectedRole) && idvalues != selectedRole)
+{
+    roles = roles.filter(function(role) 
+    {
+        return selectedRole.includes(role[0]);
+    });
+} 
+else if (!Utils.isNullOrEmpty(idvalues))
 {
     roles = roles.filter(function(role) 
     {
-- 
GitLab