From 58a504e94ee026b60d4b903b5ff9f5f91ab91547 Mon Sep 17 00:00:00 2001
From: Simon Leipold <s.leipold@adito.de>
Date: Mon, 30 Aug 2021 13:33:50 +0200
Subject: [PATCH] [Projekt: Entwicklung - Neon][TicketNr.:
 1086653][PermissionOverview zeigt vererbte Berechtigungen von Entities ohne
 gesetztes usePermission-Flag an]

---
 .../recordcontainers/jdito/contentProcess.js  | 52 +++++++------------
 1 file changed, 19 insertions(+), 33 deletions(-)

diff --git a/entity/PermissionOverview_entity/recordcontainers/jdito/contentProcess.js b/entity/PermissionOverview_entity/recordcontainers/jdito/contentProcess.js
index 36adb5c827..3046fae22e 100644
--- a/entity/PermissionOverview_entity/recordcontainers/jdito/contentProcess.js
+++ b/entity/PermissionOverview_entity/recordcontainers/jdito/contentProcess.js
@@ -46,36 +46,18 @@ rolesOrEntities = rolesOrEntitiesSelect
 
 var entityPermSetId = "";
 for each (var element in rolesOrEntities)
-{ // entry contains either a role or an entity, depending on which param exists
-    var overviewElement;
-    if (roleName)
-    {
-        overviewElement = {
-            uid: util.getNewUUID(), 
-            entity: element,
-            role: roleName,
-            view: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
-            create: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
-            read: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
-            update: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
-            "delete": PermissionEnums.FORBIDDEN_ACTION_ICON(),
-            parent: null
-        };
-    }
-    else if (entityName)
-    {
-        overviewElement = {
-            uid: util.getNewUUID(), 
-            entity: entityName,
-            role: element,
-            view: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
-            create: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
-            read: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
-            update: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
-            "delete": PermissionEnums.FORBIDDEN_ACTION_ICON(),
-            parent: null
-        }; 
-    }
+{
+    var overviewElement = {
+        uid: util.getNewUUID(), 
+        entity: entityName ? entityName : element,
+        role: roleName ? roleName : element,
+        view: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
+        create: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
+        read: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
+        update: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
+        "delete": PermissionEnums.FORBIDDEN_ACTION_ICON(),
+        parent: null
+    };
 
     entityPermSetId = PermissionUtil.getSetRoot(overviewElement.role, overviewElement.entity);
     
@@ -117,10 +99,14 @@ if (roleName && roleName.startsWith("CUSTOM_"))
                 update: PermissionEnums.FORBIDDEN_ACTION_ICON(), 
                 "delete": PermissionEnums.FORBIDDEN_ACTION_ICON(),
                 parent: null
-            }; 
+            };
             
-            overviewElement = prepareOverviewElement(set.setid, overviewElement);
-            overview = mergeElementIntoOverviewByEntity(overview, overviewElement);
+            // don't add this element if the entity is not in the list of entities with usePermission set
+            if (entitiesUsePermFlagSet.indexOf(overviewElement.entity) != -1)
+            {
+                overviewElement = prepareOverviewElement(set.setid, overviewElement);
+                overview = mergeElementIntoOverviewByEntity(overview, overviewElement);
+            }
         }  
     }
     
-- 
GitLab