From 05b3441213cd937e2ed73d76de7b8b0cf29ea083 Mon Sep 17 00:00:00 2001 From: Simon Leipold <s.leipold@adito.de> Date: Mon, 2 Aug 2021 11:43:28 +0000 Subject: [PATCH] [Projekt: Entwicklung - Neon][TicketNr.: 1082107][Rollen | Reiter sollen Berechtigungen und Mitarbeiter anzeigen] --- .../EmployeeRole_entity.aod | 1 + entity/Employee_entity/Employee_entity.aod | 4 ++ .../recordcontainers/jdito/contentProcess.js | 65 ++++++++++++++----- entity/Role_entity/Role_entity.aod | 14 ++++ .../employeewithrole_param/valueProcess.js | 4 ++ neonContext/EmployeeRole/EmployeeRole.aod | 4 ++ .../EmployeePreview_view.aod | 5 ++ .../EmployeeRolePreviewFilter_view.aod | 29 +++++++++ neonView/RoleMain_view/RoleMain_view.aod | 5 ++ 9 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 entity/Role_entity/entityfields/employeewithrole/children/employeewithrole_param/valueProcess.js create mode 100644 neonView/EmployeeRolePreviewFilter_view/EmployeeRolePreviewFilter_view.aod diff --git a/entity/EmployeeRole_entity/EmployeeRole_entity.aod b/entity/EmployeeRole_entity/EmployeeRole_entity.aod index 772f769f7bc..9ea950d382e 100644 --- a/entity/EmployeeRole_entity/EmployeeRole_entity.aod +++ b/entity/EmployeeRole_entity/EmployeeRole_entity.aod @@ -4,6 +4,7 @@ <title>Role</title> <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/EmployeeRole_entity/documentation.adoc</documentation> + <grantCreate v="true" /> <grantUpdate v="true" /> <titlePlural>Roles</titlePlural> <recordContainer>jdito</recordContainer> diff --git a/entity/Employee_entity/Employee_entity.aod b/entity/Employee_entity/Employee_entity.aod index 7d17b6b50c7..373bba05405 100644 --- a/entity/Employee_entity/Employee_entity.aod +++ b/entity/Employee_entity/Employee_entity.aod @@ -351,6 +351,10 @@ <name>EmployeeContactIdWhitelist_param</name> <expose v="true" /> </entityParameter> + <entityParameter> + <name>EmployeeWithRole_param</name> + <expose v="true" /> + </entityParameter> </entityFields> <recordContainers> <jDitoRecordContainer> diff --git a/entity/Employee_entity/recordcontainers/jdito/contentProcess.js b/entity/Employee_entity/recordcontainers/jdito/contentProcess.js index 5fabbf72734..d09a96f70c7 100644 --- a/entity/Employee_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Employee_entity/recordcontainers/jdito/contentProcess.js @@ -26,26 +26,57 @@ else users = users.map(function (user) { return [ - user[tools.NAME], - user[tools.TITLE], - user[tools.PARAMS][tools.ISACTIVE], - user[tools.PARAMS][tools.FIRSTNAME], - user[tools.PARAMS][tools.LASTNAME], - user[tools.PARAMS][tools.EMAIL], - user[tools.PARAMS][tools.EMAIL], - user[tools.DESCRIPTION], - user[tools.PARAMS][tools.CONTACTID], //8 - user[tools.PARAMS].department, - "", //password - "", //confirm_password - user[tools.ROLENAMES], //for filtering - EmployeeUtils.sliceUserId(user[tools.NAME]), - user[tools.PARAMS][tools.PHONE_ADDRESS] + user[tools.NAME], + user[tools.TITLE], + user[tools.PARAMS][tools.ISACTIVE], + user[tools.PARAMS][tools.FIRSTNAME], + user[tools.PARAMS][tools.LASTNAME], + user[tools.PARAMS][tools.EMAIL], + user[tools.PARAMS][tools.EMAIL], + user[tools.DESCRIPTION], + user[tools.PARAMS][tools.CONTACTID], //8 + user[tools.PARAMS].department, + "", //password + "", //confirm_password + user[tools.ROLENAMES], //for filtering + EmployeeUtils.sliceUserId(user[tools.NAME]), + user[tools.PARAMS][tools.PHONE_ADDRESS] ]; }); var filter = vars.get("$local.filter"); +// only show employees of the selected role in the role context +if (vars.get("$param.EmployeeWithRole_param")) +{ + var employeeWithRoleFilter = { + type:"row", + name:"ROLE_FILTER", + operator:"EQUAL", + value:vars.get("$param.EmployeeWithRole_param"), + key:vars.get("$param.EmployeeWithRole_param"), + contenttype:"TEXT" + }; + if (filter.filter != null) + { + // if the filter already has atleast one child condition, add the employeeWithRole condition + filter.filter = { + type:"group", + operator:"AND", + childs:[employeeWithRoleFilter, filter.filter] + }; + } + else + { + // otherwise you have to set a new filter object with only one child condition - the employeeWithRole condition + filter.filter = { + type:"group", + operator:"AND", + childs:[employeeWithRoleFilter] + }; + } +} + //TODO: this is a workaround that filters the records manually, it should be possible to filter the users with a tools.* method var filterFields = ["UID", "TITLE", "ISACTIVE", "FIRSTNAME", "LASTNAME", "EMAIL_ADDRESS", "", "DESCRIPTION", "CONTACT_ID", "DEPARTMENT", "", "", "ROLE_FILTER", "$$$LOOKUPFIELD$$$"]; var filterFns = { @@ -72,7 +103,9 @@ var filterFns = { if (pOperator == "CONTAINS") { pRow = [pRow[1], pRow[3], pRow[4], pRow[5]]; - var filterValues = pFilterValue.split(" ").filter(function (val) {return val.trim();}); + var filterValues = pFilterValue.split(" ").filter(function (val) { + return val.trim(); + }); return filterValues.every(function (filterValue) { return pRow.some(function (fieldValue) diff --git a/entity/Role_entity/Role_entity.aod b/entity/Role_entity/Role_entity.aod index bb4d3c0d11b..15d7c2400e0 100644 --- a/entity/Role_entity/Role_entity.aod +++ b/entity/Role_entity/Role_entity.aod @@ -143,6 +143,20 @@ <name>FilterRolesWithoutPermission</name> <usePermissions v="false" /> </entityProvider> + <entityConsumer> + <name>EmployeeWithRole</name> + <dependency> + <name>dependency</name> + <entityName>Employee_entity</entityName> + <fieldName>Employees</fieldName> + </dependency> + <children> + <entityParameter> + <name>EmployeeWithRole_param</name> + <valueProcess>%aditoprj%/entity/Role_entity/entityfields/employeewithrole/children/employeewithrole_param/valueProcess.js</valueProcess> + </entityParameter> + </children> + </entityConsumer> </entityFields> <recordContainers> <jDitoRecordContainer> diff --git a/entity/Role_entity/entityfields/employeewithrole/children/employeewithrole_param/valueProcess.js b/entity/Role_entity/entityfields/employeewithrole/children/employeewithrole_param/valueProcess.js new file mode 100644 index 00000000000..f1e485c836f --- /dev/null +++ b/entity/Role_entity/entityfields/employeewithrole/children/employeewithrole_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.vars"); + +result.string(vars.get("$field.ROLENAME")); \ No newline at end of file diff --git a/neonContext/EmployeeRole/EmployeeRole.aod b/neonContext/EmployeeRole/EmployeeRole.aod index 0d7f026ed09..577a6e2b298 100644 --- a/neonContext/EmployeeRole/EmployeeRole.aod +++ b/neonContext/EmployeeRole/EmployeeRole.aod @@ -18,5 +18,9 @@ <name>7edde309-9804-4d46-8ac0-d7642f66b584</name> <view>EmployeeRoleGenericEdit_view</view> </neonViewReference> + <neonViewReference> + <name>beabcd93-3636-43e4-ad98-f4177336d2b2</name> + <view>EmployeeRolePreviewFilter_view</view> + </neonViewReference> </references> </neonContext> diff --git a/neonView/EmployeePreview_view/EmployeePreview_view.aod b/neonView/EmployeePreview_view/EmployeePreview_view.aod index d908c43392b..e9e90dfc5bd 100644 --- a/neonView/EmployeePreview_view/EmployeePreview_view.aod +++ b/neonView/EmployeePreview_view/EmployeePreview_view.aod @@ -48,5 +48,10 @@ </entityFieldLink> </fields> </genericViewTemplate> + <neonViewReference> + <name>80b4f2c5-ce49-4c7a-8f07-6054c2b7e5af</name> + <entityField>EmployeeRoles</entityField> + <view>EmployeeRolePreviewFilter_view</view> + </neonViewReference> </children> </neonView> diff --git a/neonView/EmployeeRolePreviewFilter_view/EmployeeRolePreviewFilter_view.aod b/neonView/EmployeeRolePreviewFilter_view/EmployeeRolePreviewFilter_view.aod new file mode 100644 index 00000000000..ffa270a9fdc --- /dev/null +++ b/neonView/EmployeeRolePreviewFilter_view/EmployeeRolePreviewFilter_view.aod @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.8" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.8"> + <name>EmployeeRolePreviewFilter_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <noneLayout> + <name>layout</name> + </noneLayout> + </layout> + <children> + <tableViewTemplate> + <name>EmployeeRolesTable</name> + <isCreatable v="false" /> + <isDeletable v="false" /> + <isEditable v="false" /> + <title>Roles</title> + <columns> + <neonTableColumn> + <name>bb9468d2-18c2-4a5c-9b71-51ea34d32583</name> + <entityField>ROLE</entityField> + </neonTableColumn> + <neonTableColumn> + <name>22eff75c-01dd-4bb9-9706-a202e9178176</name> + <entityField>#UID</entityField> + </neonTableColumn> + </columns> + </tableViewTemplate> + </children> +</neonView> diff --git a/neonView/RoleMain_view/RoleMain_view.aod b/neonView/RoleMain_view/RoleMain_view.aod index debbc73ead5..811373bc470 100644 --- a/neonView/RoleMain_view/RoleMain_view.aod +++ b/neonView/RoleMain_view/RoleMain_view.aod @@ -24,5 +24,10 @@ <entityField>TheirPermissions</entityField> <view>PermissionDetailFilter_view</view> </neonViewReference> + <neonViewReference> + <name>2baa9221-374a-4ac9-8e9f-09ac70d189b3</name> + <entityField>EmployeeWithRole</entityField> + <view>EmployeeFilter_view</view> + </neonViewReference> </children> </neonView> -- GitLab