From 84b247f47ba3ca67894d1074c8848a5c970c94a1 Mon Sep 17 00:00:00 2001
From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local>
Date: Mon, 1 Apr 2019 11:20:05 +0200
Subject: [PATCH] Employee optimization

---
 entity/Document_entity/Document_entity.aod    |  6 ++
 entity/Employee_entity/Employee_entity.aod    | 55 +++++++++++++++++++
 .../assignmentname_param/valueProcess.js      |  3 +
 .../assignmentrowid_param/valueProcess.js     |  4 ++
 .../assignmenttable_param/valueProcess.js     |  3 +
 .../base64string_param/valueProcess.js        |  4 ++
 .../recordcontainers/jdito/contentProcess.js  |  9 ++-
 .../recordcontainers/jdito/onInsert.js        |  1 +
 .../recordcontainers/jdito/onUpdate.js        |  1 +
 entity/Employee_entity/titleProcess.js        |  4 ++
 entity/Person_entity/Person_entity.aod        |  6 --
 .../StoredSelection_entity.aod                | 53 ++++++++++++++++++
 .../recordcontainers/jdito/contentProcess.js  | 28 ++++++++++
 .../Timetracking_entity.aod                   |  6 +-
 .../_____LANGUAGE_de/_____LANGUAGE_de.aod     |  4 ++
 .../StoredSelection/StoredSelection.aod       | 12 ++++
 .../EmployeeMain_view/EmployeeMain_view.aod   | 10 ++++
 .../EmployeePreview_view.aod                  |  4 ++
 .../StoredSelectionFilter_view.aod            | 26 +++++++++
 19 files changed, 225 insertions(+), 14 deletions(-)
 create mode 100644 entity/Employee_entity/entityfields/documents/children/assignmentname_param/valueProcess.js
 create mode 100644 entity/Employee_entity/entityfields/documents/children/assignmentrowid_param/valueProcess.js
 create mode 100644 entity/Employee_entity/entityfields/documents/children/assignmenttable_param/valueProcess.js
 create mode 100644 entity/Employee_entity/entityfields/storedselections/children/base64string_param/valueProcess.js
 create mode 100644 entity/Employee_entity/titleProcess.js
 create mode 100644 entity/StoredSelection_entity/StoredSelection_entity.aod
 create mode 100644 entity/StoredSelection_entity/recordcontainers/jdito/contentProcess.js
 create mode 100644 neonContext/StoredSelection/StoredSelection.aod
 create mode 100644 neonView/StoredSelectionFilter_view/StoredSelectionFilter_view.aod

diff --git a/entity/Document_entity/Document_entity.aod b/entity/Document_entity/Document_entity.aod
index d4c10e0ed4..6a1829f663 100644
--- a/entity/Document_entity/Document_entity.aod
+++ b/entity/Document_entity/Document_entity.aod
@@ -179,6 +179,12 @@
           <fieldName>Documents</fieldName>
           <isConsumer v="false" />
         </entityDependency>
+        <entityDependency>
+          <name>abd400df-a5a4-4750-b3a4-0476b2721161</name>
+          <entityName>Employee_entity</entityName>
+          <fieldName>Documents</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
       </dependencies>
       <children>
         <entityParameter>
diff --git a/entity/Employee_entity/Employee_entity.aod b/entity/Employee_entity/Employee_entity.aod
index 8a7cb6fe7d..496c82b042 100644
--- a/entity/Employee_entity/Employee_entity.aod
+++ b/entity/Employee_entity/Employee_entity.aod
@@ -5,10 +5,20 @@
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <onValidation>%aditoprj%/entity/Employee_entity/onValidation.js</onValidation>
   <iconId>VAADIN:GROUP</iconId>
+  <titleProcess>%aditoprj%/entity/Employee_entity/titleProcess.js</titleProcess>
   <recordContainer>jdito</recordContainer>
   <entityFields>
     <entityProvider>
       <name>#PROVIDER</name>
+      <lookupIdfield>CONTACT_ID</lookupIdfield>
+      <dependencies>
+        <entityDependency>
+          <name>823f9c90-c834-4e37-a47b-b3756fd28182</name>
+          <entityName>Timetracking_entity</entityName>
+          <fieldName>Employees</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
+      </dependencies>
     </entityProvider>
     <entityField>
       <name>UID</name>
@@ -25,6 +35,7 @@
       <name>CONTACT_ID</name>
       <title>Person</title>
       <consumer>Contacts</consumer>
+      <linkedContext>Person</linkedContext>
       <mandatory v="false" />
       <onValidation>%aditoprj%/entity/Employee_entity/entityfields/contact_id/onValidation.js</onValidation>
     </entityField>
@@ -175,6 +186,49 @@
         </entityParameter>
       </children>
     </entityConsumer>
+    <entityConsumer>
+      <name>Documents</name>
+      <title>Documents</title>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>Document_entity</entityName>
+        <fieldName>Documents</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>AssignmentName_param</name>
+          <valueProcess>%aditoprj%/entity/Employee_entity/entityfields/documents/children/assignmentname_param/valueProcess.js</valueProcess>
+        </entityParameter>
+        <entityParameter>
+          <name>AssignmentTable_param</name>
+          <valueProcess>%aditoprj%/entity/Employee_entity/entityfields/documents/children/assignmenttable_param/valueProcess.js</valueProcess>
+        </entityParameter>
+        <entityParameter>
+          <name>AssignmentRowId_param</name>
+          <valueProcess>%aditoprj%/entity/Employee_entity/entityfields/documents/children/assignmentrowid_param/valueProcess.js</valueProcess>
+        </entityParameter>
+      </children>
+    </entityConsumer>
+    <entityConsumer>
+      <name>StoredSelections</name>
+      <title>Stored selections</title>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>StoredSelection_entity</entityName>
+        <fieldName>StoredSelections</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>Base64String_param</name>
+          <valueProcess>%aditoprj%/entity/Employee_entity/entityfields/storedselections/children/base64string_param/valueProcess.js</valueProcess>
+        </entityParameter>
+      </children>
+    </entityConsumer>
+    <entityField>
+      <name>STORED_SELECTIONS</name>
+    </entityField>
   </entityFields>
   <recordContainers>
     <jDitoRecordContainer>
@@ -194,6 +248,7 @@
         <element>DESCRIPTION.value</element>
         <element>CONTACT_ID.value</element>
         <element>CONTACT_ID.displayValue</element>
+        <element>STORED_SELECTIONS.value</element>
       </recordFields>
     </jDitoRecordContainer>
   </recordContainers>
diff --git a/entity/Employee_entity/entityfields/documents/children/assignmentname_param/valueProcess.js b/entity/Employee_entity/entityfields/documents/children/assignmentname_param/valueProcess.js
new file mode 100644
index 0000000000..f002ad73ad
--- /dev/null
+++ b/entity/Employee_entity/entityfields/documents/children/assignmentname_param/valueProcess.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string("DOCUMENT");
\ No newline at end of file
diff --git a/entity/Employee_entity/entityfields/documents/children/assignmentrowid_param/valueProcess.js b/entity/Employee_entity/entityfields/documents/children/assignmentrowid_param/valueProcess.js
new file mode 100644
index 0000000000..24b12e282d
--- /dev/null
+++ b/entity/Employee_entity/entityfields/documents/children/assignmentrowid_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.CONTACT_ID"));
\ No newline at end of file
diff --git a/entity/Employee_entity/entityfields/documents/children/assignmenttable_param/valueProcess.js b/entity/Employee_entity/entityfields/documents/children/assignmenttable_param/valueProcess.js
new file mode 100644
index 0000000000..d8e665c062
--- /dev/null
+++ b/entity/Employee_entity/entityfields/documents/children/assignmenttable_param/valueProcess.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string("EMPLOYEE");
\ No newline at end of file
diff --git a/entity/Employee_entity/entityfields/storedselections/children/base64string_param/valueProcess.js b/entity/Employee_entity/entityfields/storedselections/children/base64string_param/valueProcess.js
new file mode 100644
index 0000000000..d3297d7eb8
--- /dev/null
+++ b/entity/Employee_entity/entityfields/storedselections/children/base64string_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.STORED_SELECTIONS"));
\ No newline at end of file
diff --git a/entity/Employee_entity/recordcontainers/jdito/contentProcess.js b/entity/Employee_entity/recordcontainers/jdito/contentProcess.js
index 71470598bf..98ec35774e 100644
--- a/entity/Employee_entity/recordcontainers/jdito/contentProcess.js
+++ b/entity/Employee_entity/recordcontainers/jdito/contentProcess.js
@@ -1,4 +1,3 @@
-import("system.logging");
 import("system.vars");
 import("system.result");
 import("system.tools");
@@ -11,7 +10,7 @@ else
     users = tools.getStoredUsers().map(function (row) {return row[1];});
 users = users.map(function (user)
 {
-    user = tools.getUser(user);
+    user = tools.getUser(user, tools.PROFILE_FULL);
     return [
         user[tools.TITLE],
         user[tools.TITLE],
@@ -19,13 +18,13 @@ users = users.map(function (user)
         user[tools.PARAMS][tools.FIRSTNAME],
         user[tools.PARAMS][tools.LASTNAME],
         user[tools.PARAMS][tools.EMAIL],
-        user[tools.PARAMS][tools.DESCRIPTION],
+        user[tools.DESCRIPTION],
         user[tools.PARAMS][tools.CONTACTID],
-        user[tools.PARAMS][tools.CONTACTID]
+        user[tools.PARAMS][tools.CONTACTID],
+        user[tools.PARAMS][tools.FRAME_STOREDSEARCHES]
     ];
 });
 
 var filter = vars.exists("$local.filter") && vars.get("$local.filter");
-//logging.log(filter)
 
 result.object(users);
\ No newline at end of file
diff --git a/entity/Employee_entity/recordcontainers/jdito/onInsert.js b/entity/Employee_entity/recordcontainers/jdito/onInsert.js
index 070b796b0c..e771eb763f 100644
--- a/entity/Employee_entity/recordcontainers/jdito/onInsert.js
+++ b/entity/Employee_entity/recordcontainers/jdito/onInsert.js
@@ -9,6 +9,7 @@ params[tools.LASTNAME] = vars.get("$field.LASTNAME");
 params[tools.EMAIL] = vars.get("$field.EMAIL_ADDRESS");
 params[tools.CALENDARID] = vars.get("$field.EMAIL_ADDRESS");
 params[tools.CONTACTID] = vars.get("$field.CONTACT_ID");
+params[tools.DESCRIPTION] = vars.get("$field.DESCRIPTION");
 
 user[tools.TITLE] = vars.get("$field.TITLE");
 user[tools.PARAMS] = params;
diff --git a/entity/Employee_entity/recordcontainers/jdito/onUpdate.js b/entity/Employee_entity/recordcontainers/jdito/onUpdate.js
index 7d445e2474..f487449ce4 100644
--- a/entity/Employee_entity/recordcontainers/jdito/onUpdate.js
+++ b/entity/Employee_entity/recordcontainers/jdito/onUpdate.js
@@ -9,6 +9,7 @@ user[tools.PARAMS][tools.LASTNAME] = vars.get("$field.LASTNAME");
 user[tools.PARAMS][tools.EMAIL] = vars.get("$field.EMAIL_ADDRESS");
 user[tools.PARAMS][tools.CALENDARID] = vars.get("$field.EMAIL_ADDRESS");
 user[tools.PARAMS][tools.CONTACTID] = vars.get("$field.CONTACT_ID");
+user[tools.PARAMS][tools.DESCRIPTION] = vars.get("$field.DESCRIPTION");
 
 if (vars.exists("$param.passwordChange_param") && vars.get("$param.passwordChange_param") 
     && vars.get("$field.PASSWORD") == vars.get("$field.CONFIRM_PASSWORD"))
diff --git a/entity/Employee_entity/titleProcess.js b/entity/Employee_entity/titleProcess.js
new file mode 100644
index 0000000000..2cb5fabc54
--- /dev/null
+++ b/entity/Employee_entity/titleProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string((vars.get("$field.FIRSTNAME") + " " + vars.get("$field.LASTNAME")).trim());
\ No newline at end of file
diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod
index 2c8d411de9..5883d8dc24 100644
--- a/entity/Person_entity/Person_entity.aod
+++ b/entity/Person_entity/Person_entity.aod
@@ -279,12 +279,6 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
           <fieldName>ContactEditors</fieldName>
           <isConsumer v="false" />
         </entityDependency>
-        <entityDependency>
-          <name>f5b4d286-9f5e-4b13-8dca-d9b04186f6ca</name>
-          <entityName>Timetracking_entity</entityName>
-          <fieldName>Contacts</fieldName>
-          <isConsumer v="false" />
-        </entityDependency>
         <entityDependency>
           <name>ffdbb464-fa37-4bb7-a66d-d9e0d3a9bc56</name>
           <entityName>Activity_entity</entityName>
diff --git a/entity/StoredSelection_entity/StoredSelection_entity.aod b/entity/StoredSelection_entity/StoredSelection_entity.aod
new file mode 100644
index 0000000000..97ed60b10e
--- /dev/null
+++ b/entity/StoredSelection_entity/StoredSelection_entity.aod
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.0">
+  <name>StoredSelection_entity</name>
+  <title>Stored selections</title>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <recordContainer>jdito</recordContainer>
+  <entityFields>
+    <entityProvider>
+      <name>#PROVIDER</name>
+    </entityProvider>
+    <entityField>
+      <name>UID</name>
+    </entityField>
+    <entityParameter>
+      <name>Base64String_param</name>
+      <expose v="true" />
+      <description>PARAMETER</description>
+    </entityParameter>
+    <entityProvider>
+      <name>StoredSelections</name>
+      <fieldType>DEPENDENCY_IN</fieldType>
+      <dependencies>
+        <entityDependency>
+          <name>1386345f-0ed8-4c82-b96d-a249775314ee</name>
+          <entityName>Employee_entity</entityName>
+          <fieldName>StoredSelections</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
+      </dependencies>
+    </entityProvider>
+    <entityField>
+      <name>CONTEXT_NAME</name>
+      <title>Module</title>
+      <state>READONLY</state>
+    </entityField>
+    <entityField>
+      <name>SELECTION_TITLE</name>
+      <title>Name</title>
+      <state>READONLY</state>
+    </entityField>
+  </entityFields>
+  <recordContainers>
+    <jDitoRecordContainer>
+      <name>jdito</name>
+      <contentProcess>%aditoprj%/entity/StoredSelection_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
+      <recordFields>
+        <element>UID.value</element>
+        <element>CONTEXT_NAME.value</element>
+        <element>SELECTION_TITLE.value</element>
+      </recordFields>
+    </jDitoRecordContainer>
+  </recordContainers>
+</entity>
diff --git a/entity/StoredSelection_entity/recordcontainers/jdito/contentProcess.js b/entity/StoredSelection_entity/recordcontainers/jdito/contentProcess.js
new file mode 100644
index 0000000000..cc4302b632
--- /dev/null
+++ b/entity/StoredSelection_entity/recordcontainers/jdito/contentProcess.js
@@ -0,0 +1,28 @@
+import("system.result");
+import("system.pack");
+import("system.util");
+import("system.vars");
+
+var records = [];
+if (vars.exists("$param.Base64String_param") && vars.get("$param.Base64String_param"))
+{
+    var codedSelections = pack.gunzip(vars.get("$param.Base64String_param"));
+
+    var selections = new XML(util.decodeBase64String(codedSelections));
+    selections = selections.FRAME;
+    for (let i in selections)
+    {
+        context = selections[i];
+        var contextName = context.NAME;
+        if (contextName)
+        {
+            var title = context.STORE.(ID == "#STORE_SAVED").ELEMENT.TITLE;
+            for (let ii in title)
+            {
+                records.push([(contextName + title[ii]), contextName, title[ii]]);
+            }
+        }
+    }
+}
+
+result.object(records);
\ No newline at end of file
diff --git a/entity/Timetracking_entity/Timetracking_entity.aod b/entity/Timetracking_entity/Timetracking_entity.aod
index 2ed0a5850b..8b75e31a16 100644
--- a/entity/Timetracking_entity/Timetracking_entity.aod
+++ b/entity/Timetracking_entity/Timetracking_entity.aod
@@ -37,7 +37,7 @@
     <entityField>
       <name>CONTACT_ID</name>
       <title>Creator</title>
-      <consumer>Contacts</consumer>
+      <consumer>Employees</consumer>
       <linkedContext>Person</linkedContext>
       <mandatory v="true" />
     </entityField>
@@ -87,11 +87,11 @@
       </children>
     </entityProvider>
     <entityConsumer>
-      <name>Contacts</name>
+      <name>Employees</name>
       <fieldType>DEPENDENCY_OUT</fieldType>
       <dependency>
         <name>dependency</name>
-        <entityName>Person_entity</entityName>
+        <entityName>Employee_entity</entityName>
         <fieldName>#PROVIDER</fieldName>
       </dependency>
     </entityConsumer>
diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
index 1745419852..605049e492 100644
--- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
+++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
@@ -74,6 +74,10 @@
       <key>Filename</key>
       <value>Dateiname</value>
     </entry>
+    <entry>
+      <key>Stored selections</key>
+      <value>Gespeicherte Suchen</value>
+    </entry>
     <entry>
       <key>Male</key>
       <value>Männlich</value>
diff --git a/neonContext/StoredSelection/StoredSelection.aod b/neonContext/StoredSelection/StoredSelection.aod
new file mode 100644
index 0000000000..cda8fb5311
--- /dev/null
+++ b/neonContext/StoredSelection/StoredSelection.aod
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0">
+  <name>StoredSelection</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <entity>StoredSelection_entity</entity>
+  <references>
+    <neonViewReference>
+      <name>8ab7727b-5dc7-47bb-9034-079d84ede3a3</name>
+      <view>StoredSelectionFilter_view</view>
+    </neonViewReference>
+  </references>
+</neonContext>
diff --git a/neonView/EmployeeMain_view/EmployeeMain_view.aod b/neonView/EmployeeMain_view/EmployeeMain_view.aod
index 11918294c2..90103f5684 100644
--- a/neonView/EmployeeMain_view/EmployeeMain_view.aod
+++ b/neonView/EmployeeMain_view/EmployeeMain_view.aod
@@ -29,5 +29,15 @@
       <entityField>AttributeTree</entityField>
       <view>AttributeRelationTree_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>169d3ae7-d688-42fd-9097-77bbd9bfb81f</name>
+      <entityField>Documents</entityField>
+      <view>DocumentFilter_view</view>
+    </neonViewReference>
+    <neonViewReference>
+      <name>aaca4c8c-7953-43d8-9390-53b78d86863a</name>
+      <entityField>StoredSelections</entityField>
+      <view>StoredSelectionFilter_view</view>
+    </neonViewReference>
   </children>
 </neonView>
diff --git a/neonView/EmployeePreview_view/EmployeePreview_view.aod b/neonView/EmployeePreview_view/EmployeePreview_view.aod
index 2cbb42497c..a96af6d20e 100644
--- a/neonView/EmployeePreview_view/EmployeePreview_view.aod
+++ b/neonView/EmployeePreview_view/EmployeePreview_view.aod
@@ -20,6 +20,10 @@
       <showDrawer v="true" />
       <entityField>#ENTITY</entityField>
       <fields>
+        <entityFieldLink>
+          <name>a5f8b519-26d8-4824-b9cf-9119c03b1bd8</name>
+          <entityField>CONTACT_ID</entityField>
+        </entityFieldLink>
         <entityFieldLink>
           <name>0bda9209-1437-49eb-98b7-6edea9c6836a</name>
           <entityField>DEPARTMENT</entityField>
diff --git a/neonView/StoredSelectionFilter_view/StoredSelectionFilter_view.aod b/neonView/StoredSelectionFilter_view/StoredSelectionFilter_view.aod
new file mode 100644
index 0000000000..668cad9f84
--- /dev/null
+++ b/neonView/StoredSelectionFilter_view/StoredSelectionFilter_view.aod
@@ -0,0 +1,26 @@
+<?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.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.0">
+  <name>StoredSelectionFilter_view</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <layout>
+    <boxLayout>
+      <name>layout</name>
+    </boxLayout>
+  </layout>
+  <children>
+    <tableViewTemplate>
+      <name>Table</name>
+      <entityField>#ENTITY</entityField>
+      <columns>
+        <neonTableColumn>
+          <name>713574de-2d9c-4006-93a3-3860fb145c26</name>
+          <entityField>CONTEXT_NAME</entityField>
+        </neonTableColumn>
+        <neonTableColumn>
+          <name>4cc4d5ff-24cf-46d9-9941-cda11e445a17</name>
+          <entityField>SELECTION_TITLE</entityField>
+        </neonTableColumn>
+      </columns>
+    </tableViewTemplate>
+  </children>
+</neonView>
-- 
GitLab