From 4978a83144ac552b669a5fb4e65e34906fb009dd Mon Sep 17 00:00:00 2001
From: Carolin Wimmer <c.wimmer@adito.de>
Date: Thu, 5 Nov 2020 14:33:24 +0100
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Crowd-Development=20/=20Besuch=20vo?=
 =?UTF-8?q?r=20Ort][TicketNr.:=201067065][Wochenpl=C3=A4ne=20der=20Mitarbe?=
 =?UTF-8?q?iter]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 entity/Employee_entity/Employee_entity.aod    |  6 +++
 .../VisitPlanEmployeeWeek_entity.aod          | 39 ++++++++++++++++---
 .../contact_id/displayValueProcess.js         |  5 +++
 .../onlyactives_param/valueProcess.js         |  3 ++
 .../entityfields/week/onValidation.js         |  2 +-
 .../entityfields/year/valueProcess.js         |  1 -
 .../recordcontainers/db/conditionProcess.js   | 10 -----
 .../person_id.displayvalue/expression.js      |  5 ---
 .../VisitPlanEmployeeWeekFilter_view.aod      | 10 ++++-
 9 files changed, 57 insertions(+), 24 deletions(-)
 create mode 100644 entity/VisitPlanEmployeeWeek_entity/entityfields/contact_id/displayValueProcess.js
 create mode 100644 entity/VisitPlanEmployeeWeek_entity/entityfields/employees/children/onlyactives_param/valueProcess.js
 delete mode 100644 entity/VisitPlanEmployeeWeek_entity/recordcontainers/db/conditionProcess.js
 delete mode 100644 entity/VisitPlanEmployeeWeek_entity/recordcontainers/db/recordfieldmappings/person_id.displayvalue/expression.js

diff --git a/entity/Employee_entity/Employee_entity.aod b/entity/Employee_entity/Employee_entity.aod
index 2ed1146344..e196ea05d8 100644
--- a/entity/Employee_entity/Employee_entity.aod
+++ b/entity/Employee_entity/Employee_entity.aod
@@ -274,6 +274,12 @@
           <fieldName>Employees</fieldName>
           <isConsumer v="false" />
         </entityDependency>
+        <entityDependency>
+          <name>14d61385-28fb-40b2-a31a-a5764a8da2f0</name>
+          <entityName>VisitPlanEmployeeWeek_entity</entityName>
+          <fieldName>Employees</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
       </dependencies>
       <children>
         <entityParameter>
diff --git a/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod b/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod
index ef198c6a74..5357362790 100644
--- a/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod
+++ b/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod
@@ -18,13 +18,20 @@
     <entityField>
       <name>YEAR</name>
       <title>Year</title>
+      <contentType>TEXT</contentType>
       <resolution>YEAR</resolution>
+      <outputFormat>yyyy</outputFormat>
+      <inputFormat>yyyy</inputFormat>
+      <groupable v="true" />
+      <mandatory v="true" />
       <valueProcess>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/entityfields/year/valueProcess.js</valueProcess>
       <onValidation>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/entityfields/year/onValidation.js</onValidation>
     </entityField>
     <entityField>
       <name>WEEK</name>
       <title>Week</title>
+      <groupable v="true" />
+      <mandatory v="true" />
       <dropDownProcess>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/entityfields/week/dropDownProcess.js</dropDownProcess>
       <valueProcess>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/entityfields/week/valueProcess.js</valueProcess>
       <onValidation>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/entityfields/week/onValidation.js</onValidation>
@@ -36,8 +43,12 @@
     <entityField>
       <name>CONTACT_ID</name>
       <title>Employee</title>
-      <state>INVISIBLE</state>
+      <consumer>Employees</consumer>
+      <groupable v="true" />
+      <linkedContext>Person</linkedContext>
+      <state>AUTO</state>
       <valueProcess>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/entityfields/contact_id/valueProcess.js</valueProcess>
+      <displayValueProcess>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/entityfields/contact_id/displayValueProcess.js</displayValueProcess>
     </entityField>
     <entityField>
       <name>icon</name>
@@ -100,12 +111,25 @@
       <name>#PROVIDER_AGGREGATES</name>
       <useAggregates v="true" />
     </entityProvider>
+    <entityConsumer>
+      <name>Employees</name>
+      <dependency>
+        <name>dependency</name>
+        <entityName>Employee_entity</entityName>
+        <fieldName>Employees</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>OnlyActives_param</name>
+          <valueProcess>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/entityfields/employees/children/onlyactives_param/valueProcess.js</valueProcess>
+        </entityParameter>
+      </children>
+    </entityConsumer>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
       <name>db</name>
       <alias>Data_alias</alias>
-      <conditionProcess>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
       <orderClauseProcess>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess>
       <linkInformation>
         <linkInformation>
@@ -124,10 +148,12 @@
         <dbRecordFieldMapping>
           <name>YEAR.value</name>
           <recordfield>VISITPLANEMPLOYEEWEEK.VISITPLAN_YEAR</recordfield>
+          <isFilterable v="true" />
         </dbRecordFieldMapping>
         <dbRecordFieldMapping>
           <name>WEEK.value</name>
           <recordfield>VISITPLANEMPLOYEEWEEK.VISITPLAN_WEEK</recordfield>
+          <isFilterable v="true" />
         </dbRecordFieldMapping>
         <dbRecordFieldMapping>
           <name>INFO.value</name>
@@ -136,11 +162,12 @@
         <dbRecordFieldMapping>
           <name>CONTACT_ID.value</name>
           <recordfield>VISITPLANEMPLOYEEWEEK.CONTACT_ID</recordfield>
+          <isFilterable v="true" />
         </dbRecordFieldMapping>
-        <dbRecordFieldMapping>
-          <name>CONTACT_ID.displayValue</name>
-          <expression>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/recordcontainers/db/recordfieldmappings/person_id.displayvalue/expression.js</expression>
-        </dbRecordFieldMapping>
+        <consumerMapping>
+          <name>Employees</name>
+          <isFilterable v="false" />
+        </consumerMapping>
       </recordFieldMappings>
     </dbRecordContainer>
   </recordContainers>
diff --git a/entity/VisitPlanEmployeeWeek_entity/entityfields/contact_id/displayValueProcess.js b/entity/VisitPlanEmployeeWeek_entity/entityfields/contact_id/displayValueProcess.js
new file mode 100644
index 0000000000..edca7faf0b
--- /dev/null
+++ b/entity/VisitPlanEmployeeWeek_entity/entityfields/contact_id/displayValueProcess.js
@@ -0,0 +1,5 @@
+import("system.vars");
+import("Contact_lib");
+import("system.result");
+
+result.string(ContactUtils.getFullTitleByContactId(vars.get("$field.CONTACT_ID"), false));
\ No newline at end of file
diff --git a/entity/VisitPlanEmployeeWeek_entity/entityfields/employees/children/onlyactives_param/valueProcess.js b/entity/VisitPlanEmployeeWeek_entity/entityfields/employees/children/onlyactives_param/valueProcess.js
new file mode 100644
index 0000000000..599bfc3519
--- /dev/null
+++ b/entity/VisitPlanEmployeeWeek_entity/entityfields/employees/children/onlyactives_param/valueProcess.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string(true)
\ No newline at end of file
diff --git a/entity/VisitPlanEmployeeWeek_entity/entityfields/week/onValidation.js b/entity/VisitPlanEmployeeWeek_entity/entityfields/week/onValidation.js
index cff756f713..5a6c233569 100644
--- a/entity/VisitPlanEmployeeWeek_entity/entityfields/week/onValidation.js
+++ b/entity/VisitPlanEmployeeWeek_entity/entityfields/week/onValidation.js
@@ -9,7 +9,7 @@ import("system.eMath");
 
 var year = eMath.absInt(vars.get("$field.YEAR"));
 var week = vars.get("$local.value");
-var user = EmployeeUtils.getCurrentContactId();
+var user = vars.get("$field.CONTACT_ID");
 
 var weekEntry = newSelect("VISITPLANEMPLOYEEWEEKID")
             .from("VISITPLANEMPLOYEEWEEK")
diff --git a/entity/VisitPlanEmployeeWeek_entity/entityfields/year/valueProcess.js b/entity/VisitPlanEmployeeWeek_entity/entityfields/year/valueProcess.js
index c79b83acb5..f58c37080a 100644
--- a/entity/VisitPlanEmployeeWeek_entity/entityfields/year/valueProcess.js
+++ b/entity/VisitPlanEmployeeWeek_entity/entityfields/year/valueProcess.js
@@ -4,6 +4,5 @@ import("system.result");
 import("system.neon");
 import("system.vars");
 
-//use current year if recordstate = new and this field empty
 if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null)
     result.string(datetime.toDate(vars.get("$sys.date"), "yyyy"));
\ No newline at end of file
diff --git a/entity/VisitPlanEmployeeWeek_entity/recordcontainers/db/conditionProcess.js b/entity/VisitPlanEmployeeWeek_entity/recordcontainers/db/conditionProcess.js
deleted file mode 100644
index dfed3430a9..0000000000
--- a/entity/VisitPlanEmployeeWeek_entity/recordcontainers/db/conditionProcess.js
+++ /dev/null
@@ -1,10 +0,0 @@
-import("system.logging");
-import("Sql_lib");
-import("Employee_lib");
-import("system.result");
-
-var cond = newWhere();
-
-cond.and("VISITPLANEMPLOYEEWEEK.CONTACT_ID", EmployeeUtils.getCurrentContactId());
-
-result.string(cond);
\ No newline at end of file
diff --git a/entity/VisitPlanEmployeeWeek_entity/recordcontainers/db/recordfieldmappings/person_id.displayvalue/expression.js b/entity/VisitPlanEmployeeWeek_entity/recordcontainers/db/recordfieldmappings/person_id.displayvalue/expression.js
deleted file mode 100644
index b061026da3..0000000000
--- a/entity/VisitPlanEmployeeWeek_entity/recordcontainers/db/recordfieldmappings/person_id.displayvalue/expression.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import("system.result");
-import("system.vars");
-import("Person_lib");
-
-result.string(PersUtils.getResolvingDisplaySubSql("VISITPLANEMPLOYEEWEEK.CONTACT_ID"));
\ No newline at end of file
diff --git a/neonView/VisitPlanEmployeeWeekFilter_view/VisitPlanEmployeeWeekFilter_view.aod b/neonView/VisitPlanEmployeeWeekFilter_view/VisitPlanEmployeeWeekFilter_view.aod
index 6de254467a..ae5dc231a5 100644
--- a/neonView/VisitPlanEmployeeWeekFilter_view/VisitPlanEmployeeWeekFilter_view.aod
+++ b/neonView/VisitPlanEmployeeWeekFilter_view/VisitPlanEmployeeWeekFilter_view.aod
@@ -2,7 +2,7 @@
 <neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.6" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.6">
   <name>VisitPlanEmployeeWeekFilter_view</name>
   <majorModelMode>DISTRIBUTED</majorModelMode>
-  <filterable v="false" />
+  <filterable v="true" />
   <layout>
     <groupLayout>
       <name>layout</name>
@@ -27,6 +27,10 @@
           <name>41e665d5-0bcf-4e33-8080-809d839da15d</name>
           <entityField>YEAR</entityField>
         </neonTableColumn>
+        <neonTableColumn>
+          <name>51af23cb-462b-4b40-8923-97c9c9120dd1</name>
+          <entityField>CONTACT_ID</entityField>
+        </neonTableColumn>
         <neonTableColumn>
           <name>a5b55587-841d-42d5-b4b7-eff55f6f6858</name>
           <entityField>entriescount</entityField>
@@ -68,6 +72,10 @@
           <name>6a11aa05-3879-46f2-9944-2006d9caf928</name>
           <entityField>YEAR</entityField>
         </neonTreeTableColumn>
+        <neonTreeTableColumn>
+          <name>d8055245-cf8d-40cd-ad59-627c564d831d</name>
+          <entityField>CONTACT_ID</entityField>
+        </neonTreeTableColumn>
         <neonTreeTableColumn>
           <name>8db139d9-7dd7-4ea2-9c73-1c0accec2ef5</name>
           <entityField>entriescount</entityField>
-- 
GitLab