From d7dda789ce0b11c214591241d7e9eceb8644d7d1 Mon Sep 17 00:00:00 2001
From: "S.Listl" <s.listl@adito.de>
Date: Tue, 25 Aug 2020 11:54:53 +0200
Subject: [PATCH] Scan Service fixes

---
 .../AnyContact_entity/AnyContact_entity.aod   |  1 -
 entity/AnyContact_entity/afterUiInit.js       |  0
 entity/Contact_entity/Contact_entity.aod      |  1 -
 entity/Contact_entity/afterUiInit.js          |  0
 .../recordcontainers/index/query.js           |  1 +
 entity/Person_entity/Person_entity.aod        | 10 -----
 .../entityfields/newtask/iconIdProcess.js     |  0
 .../entityfields/opentaskview/stateProcess.js |  0
 .../WorkflowTask_entity.aod                   |  1 +
 entity/WorkflowTask_entity/afterSave.js       | 38 +++++++++++++++++++
 .../recordcontainers/jdito/onUpdate.js        | 34 -----------------
 neonContext/Social/Social.aod                 |  2 -
 .../PersonPreview_view/PersonPreview_view.aod |  3 --
 13 files changed, 40 insertions(+), 51 deletions(-)
 delete mode 100644 entity/AnyContact_entity/afterUiInit.js
 delete mode 100644 entity/Contact_entity/afterUiInit.js
 delete mode 100644 entity/Person_entity/entityfields/newtask/iconIdProcess.js
 delete mode 100644 entity/Person_entity/entityfields/opentaskview/stateProcess.js
 create mode 100644 entity/WorkflowTask_entity/afterSave.js

diff --git a/entity/AnyContact_entity/AnyContact_entity.aod b/entity/AnyContact_entity/AnyContact_entity.aod
index 1fa8e83a7e..5207437071 100644
--- a/entity/AnyContact_entity/AnyContact_entity.aod
+++ b/entity/AnyContact_entity/AnyContact_entity.aod
@@ -4,7 +4,6 @@
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <documentation>%aditoprj%/entity/AnyContact_entity/documentation.adoc</documentation>
   <contentTitleProcess>%aditoprj%/entity/AnyContact_entity/contentTitleProcess.js</contentTitleProcess>
-  <afterUiInit>%aditoprj%/entity/AnyContact_entity/afterUiInit.js</afterUiInit>
   <initFilterProcess>%aditoprj%/entity/AnyContact_entity/initFilterProcess.js</initFilterProcess>
   <imageProcess>%aditoprj%/entity/AnyContact_entity/imageProcess.js</imageProcess>
   <recordContainer>db</recordContainer>
diff --git a/entity/AnyContact_entity/afterUiInit.js b/entity/AnyContact_entity/afterUiInit.js
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/entity/Contact_entity/Contact_entity.aod b/entity/Contact_entity/Contact_entity.aod
index 542030903e..ad05310a9d 100644
--- a/entity/Contact_entity/Contact_entity.aod
+++ b/entity/Contact_entity/Contact_entity.aod
@@ -8,7 +8,6 @@
   <grantUpdateProcess>%aditoprj%/entity/Contact_entity/grantUpdateProcess.js</grantUpdateProcess>
   <grantDeleteProcess>%aditoprj%/entity/Contact_entity/grantDeleteProcess.js</grantDeleteProcess>
   <contentTitleProcess>%aditoprj%/entity/Contact_entity/contentTitleProcess.js</contentTitleProcess>
-  <afterUiInit>%aditoprj%/entity/Contact_entity/afterUiInit.js</afterUiInit>
   <onValidation>%aditoprj%/entity/Contact_entity/onValidation.js</onValidation>
   <initFilterProcess>%aditoprj%/entity/Contact_entity/initFilterProcess.js</initFilterProcess>
   <iconId>VAADIN:USERS</iconId>
diff --git a/entity/Contact_entity/afterUiInit.js b/entity/Contact_entity/afterUiInit.js
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/entity/Organisation_entity/recordcontainers/index/query.js b/entity/Organisation_entity/recordcontainers/index/query.js
index 665f7ab71f..668b6b227f 100644
--- a/entity/Organisation_entity/recordcontainers/index/query.js
+++ b/entity/Organisation_entity/recordcontainers/index/query.js
@@ -1,3 +1,4 @@
+import("KeywordRegistry_basic");
 import("system.translate");
 import("system.result");
 import("system.vars");
diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod
index a0fac3286f..7eb5a44a80 100644
--- a/entity/Person_entity/Person_entity.aod
+++ b/entity/Person_entity/Person_entity.aod
@@ -1012,7 +1012,6 @@
       <title>New task</title>
       <onActionProcess>%aditoprj%/entity/Person_entity/entityfields/newtask/onActionProcess.js</onActionProcess>
       <iconId>VAADIN:TASKS</iconId>
-      <iconIdProcess>%aditoprj%/entity/Person_entity/entityfields/newtask/iconIdProcess.js</iconIdProcess>
     </entityActionField>
     <entityActionField>
       <name>addToCampaign</name>
@@ -1141,12 +1140,6 @@
       <iconId>VAADIN:ENVELOPE</iconId>
       <stateProcess>%aditoprj%/entity/Person_entity/entityfields/newletter/stateProcess.js</stateProcess>
     </entityActionField>
-    <entityActionField>
-      <name>openTaskView</name>
-      <isMenuAction v="false" />
-      <isObjectAction v="false" />
-      <stateProcess>%aditoprj%/entity/Person_entity/entityfields/opentaskview/stateProcess.js</stateProcess>
-    </entityActionField>
     <entityActionField>
       <name>startWorkflow</name>
       <title>Start workflow</title>
@@ -1583,9 +1576,6 @@
           <recordfield>PERSON.PERSONID</recordfield>
           <aggregateType>COUNT</aggregateType>
         </aggregateFieldDbMapping>
-        <dbRecordFieldMapping>
-          <name>COUNT.value</name>
-        </dbRecordFieldMapping>
       </recordFieldMappings>
       <filterExtensions>
         <filterExtensionSet>
diff --git a/entity/Person_entity/entityfields/newtask/iconIdProcess.js b/entity/Person_entity/entityfields/newtask/iconIdProcess.js
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/entity/Person_entity/entityfields/opentaskview/stateProcess.js b/entity/Person_entity/entityfields/opentaskview/stateProcess.js
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/entity/WorkflowTask_entity/WorkflowTask_entity.aod b/entity/WorkflowTask_entity/WorkflowTask_entity.aod
index 938fbcdc99..ceb8ba0d2d 100644
--- a/entity/WorkflowTask_entity/WorkflowTask_entity.aod
+++ b/entity/WorkflowTask_entity/WorkflowTask_entity.aod
@@ -7,6 +7,7 @@
   <grantCreate v="false" />
   <grantUpdateProcess>%aditoprj%/entity/WorkflowTask_entity/grantUpdateProcess.js</grantUpdateProcess>
   <grantDelete v="false" />
+  <afterSave>%aditoprj%/entity/WorkflowTask_entity/afterSave.js</afterSave>
   <imageProcess>%aditoprj%/entity/WorkflowTask_entity/imageProcess.js</imageProcess>
   <titlePlural>Tasks</titlePlural>
   <recordContainer>jdito</recordContainer>
diff --git a/entity/WorkflowTask_entity/afterSave.js b/entity/WorkflowTask_entity/afterSave.js
new file mode 100644
index 0000000000..68fae8b0d2
--- /dev/null
+++ b/entity/WorkflowTask_entity/afterSave.js
@@ -0,0 +1,38 @@
+import("system.neon");
+import("system.workflow");
+import("system.vars");
+
+var entityData = vars.get("$local.entitydata");
+
+//open the next workflow task if one exists
+if (entityData["FORMRESULT"])
+{
+    var processInstanceId = entityData["PROCESSINSTANCE_ID"];
+    var createTime = entityData["CREATE_TIME"];
+
+    var loadConfig = workflow.createConfigForLoadingTasks()
+        .processInstanceId(processInstanceId);
+
+    var startVal = {
+        id : null, 
+        createTime : new Date(+createTime).toString()
+    };
+    var newestTask = JSON.parse(workflow.getTasks(loadConfig)).reduce(function (prev, curr)
+    {
+        var prevTime = Date.parse(prev.createTime);
+        var currTime = Date.parse(curr.createTime);
+
+        return prevTime > currTime ? prev : curr;
+    }, startVal);
+
+    if (newestTask.id !== null)
+        neon.openContext("WorkflowTask", "WorkflowTaskPreview_view", [newestTask.id], neon.OPERATINGSTATE_VIEW, null);
+    else
+    {
+        var params = {
+            "TaskTitle_param" : rowData["NAME.value"]
+        };
+        //if you try to open the task now, it will display "Task done"
+        neon.openContext("WorkflowTask", "WorkflowTaskPreview_view", [rowData["UID.value"]], neon.OPERATINGSTATE_VIEW, params);
+    }
+}
\ No newline at end of file
diff --git a/entity/WorkflowTask_entity/recordcontainers/jdito/onUpdate.js b/entity/WorkflowTask_entity/recordcontainers/jdito/onUpdate.js
index 9144b8ba06..911cd08a9f 100644
--- a/entity/WorkflowTask_entity/recordcontainers/jdito/onUpdate.js
+++ b/entity/WorkflowTask_entity/recordcontainers/jdito/onUpdate.js
@@ -18,39 +18,5 @@ vars.get("$local.changed").forEach(function (field)
             if (!rowData["ASSIGNEE.value"] && !vars.get("$field.ASSIGNEE"))
                 workflow.setTaskAssignee(taskId, EmployeeUtils.getCurrentUserId());
             workflow.completeTaskWithFormData(taskId, JSON.parse(value));
-            _openNextTaskIfExists(rowData["PROCESSINSTANCE_ID.value"], rowData["CREATE_TIME.value"]);
     }
 });
-
-/*
- * checks if a new task has been created for that process instance,
- * if that's the case the new task will be opened
- */
-function _openNextTaskIfExists (pProcessInstanceId, pCreateTime)
-{
-    var loadConfig = workflow.createConfigForLoadingTasks()
-        .processInstanceId(pProcessInstanceId);
-        
-    var startVal = {
-        id : null, 
-        createTime : new Date(+pCreateTime).toString()
-    };
-    var newestTask = JSON.parse(workflow.getTasks(loadConfig)).reduce(function (prev, curr)
-    {
-        var prevTime = Date.parse(prev.createTime);
-        var currTime = Date.parse(curr.createTime);
-        
-        return prevTime > currTime ? prev : curr;
-    }, startVal);
-    
-    if (newestTask.id !== null)
-        neon.openContext("WorkflowTask", "WorkflowTaskPreview_view", [newestTask.id], neon.OPERATINGSTATE_VIEW, null);
-    else
-    {
-        var params = {
-            "TaskTitle_param" : rowData["NAME.value"]
-        };
-        //if you try to open the task now, it will display "Task done"
-        neon.openContext("WorkflowTask", "WorkflowTaskPreview_view", [rowData["UID.value"]], neon.OPERATINGSTATE_VIEW, params);
-    }
-}
\ No newline at end of file
diff --git a/neonContext/Social/Social.aod b/neonContext/Social/Social.aod
index a2e96e0735..339a5a5470 100644
--- a/neonContext/Social/Social.aod
+++ b/neonContext/Social/Social.aod
@@ -3,8 +3,6 @@
   <name>Social</name>
   <title>Social</title>
   <majorModelMode>DISTRIBUTED</majorModelMode>
-  <mainView></mainView>
-  <filterView>&lt;null value&gt;</filterView>
   <entity>Social_entity</entity>
   <references>
     <neonViewReference>
diff --git a/neonView/PersonPreview_view/PersonPreview_view.aod b/neonView/PersonPreview_view/PersonPreview_view.aod
index f0f73a44de..b1717f65bc 100644
--- a/neonView/PersonPreview_view/PersonPreview_view.aod
+++ b/neonView/PersonPreview_view/PersonPreview_view.aod
@@ -91,9 +91,6 @@
     </genericViewTemplate>
     <scoreCardViewTemplate>
       <name>Scores</name>
-      <fieldActions>
-        <element>openTaskView</element>
-      </fieldActions>
       <entityField>#ENTITY</entityField>
       <fields>
         <entityFieldLink>
-- 
GitLab