From 371ed04492528832434e63c8cc7ef19a5859307b Mon Sep 17 00:00:00 2001
From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local>
Date: Wed, 2 Oct 2019 13:13:26 +0200
Subject: [PATCH] workflows

---
 .../WorkflowDefinition_entity.aod                 |  3 +++
 .../entityfields/diagram/valueProcess.js          |  2 +-
 .../entityfields/isactive/dropDownProcess.js      |  7 +++++++
 .../recordcontainers/jdito/onUpdate.js            |  5 +++++
 .../WorkflowInstance_entity.aod                   |  1 +
 .../recordcontainers/jdito/contentProcess.js      |  7 +++++++
 .../WorkflowDefinitionPreview_view.aod            | 15 +++++++++++++++
 7 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 entity/WorkflowDefinition_entity/entityfields/isactive/dropDownProcess.js
 create mode 100644 entity/WorkflowDefinition_entity/recordcontainers/jdito/onUpdate.js
 create mode 100644 entity/WorkflowInstance_entity/recordcontainers/jdito/contentProcess.js

diff --git a/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod b/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod
index dfeca41ef0..30447fcdaa 100644
--- a/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod
+++ b/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod
@@ -31,6 +31,7 @@
       <name>ISACTIVE</name>
       <title>Active</title>
       <contentType>BOOLEAN</contentType>
+      <dropDownProcess>%aditoprj%/entity/WorkflowDefinition_entity/entityfields/isactive/dropDownProcess.js</dropDownProcess>
     </entityField>
     <entityField>
       <name>FILEUPLOAD</name>
@@ -51,6 +52,7 @@
     <entityField>
       <name>VERSION</name>
       <title>Version</title>
+      <state>READONLY</state>
     </entityField>
     <entityField>
       <name>NAME</name>
@@ -73,6 +75,7 @@
       <isFilterable v="true" />
       <contentProcess>%aditoprj%/entity/WorkflowDefinition_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
       <onInsert>%aditoprj%/entity/WorkflowDefinition_entity/recordcontainers/jdito/onInsert.js</onInsert>
+      <onUpdate>%aditoprj%/entity/WorkflowDefinition_entity/recordcontainers/jdito/onUpdate.js</onUpdate>
       <recordFieldMappings>
         <jDitoRecordFieldMapping>
           <name>UID.value</name>
diff --git a/entity/WorkflowDefinition_entity/entityfields/diagram/valueProcess.js b/entity/WorkflowDefinition_entity/entityfields/diagram/valueProcess.js
index 7d8f58e356..4ce7a3f7fc 100644
--- a/entity/WorkflowDefinition_entity/entityfields/diagram/valueProcess.js
+++ b/entity/WorkflowDefinition_entity/entityfields/diagram/valueProcess.js
@@ -3,5 +3,5 @@ import("system.result");
 import("system.neon");
 import("system.workflow");
 
-if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET)
+if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_VIEW)
     result.string(workflow.getProcessDiagram(vars.get("$field.UID")));
\ No newline at end of file
diff --git a/entity/WorkflowDefinition_entity/entityfields/isactive/dropDownProcess.js b/entity/WorkflowDefinition_entity/entityfields/isactive/dropDownProcess.js
new file mode 100644
index 0000000000..a5eec56c41
--- /dev/null
+++ b/entity/WorkflowDefinition_entity/entityfields/isactive/dropDownProcess.js
@@ -0,0 +1,7 @@
+import("system.translate");
+import("system.result");
+
+result.object([
+    ["true", translate.text("Yes")],
+    ["false", translate.text("No")]
+]);
\ No newline at end of file
diff --git a/entity/WorkflowDefinition_entity/recordcontainers/jdito/onUpdate.js b/entity/WorkflowDefinition_entity/recordcontainers/jdito/onUpdate.js
new file mode 100644
index 0000000000..23cf24a9af
--- /dev/null
+++ b/entity/WorkflowDefinition_entity/recordcontainers/jdito/onUpdate.js
@@ -0,0 +1,5 @@
+import("system.vars");
+import("system.workflow");
+
+if (vars.get("$local.changed"))
+var rowdata = vars.get("$local.rowdata");
diff --git a/entity/WorkflowInstance_entity/WorkflowInstance_entity.aod b/entity/WorkflowInstance_entity/WorkflowInstance_entity.aod
index 492ca5a5c6..3015fe1186 100644
--- a/entity/WorkflowInstance_entity/WorkflowInstance_entity.aod
+++ b/entity/WorkflowInstance_entity/WorkflowInstance_entity.aod
@@ -31,6 +31,7 @@
   <recordContainers>
     <jDitoRecordContainer>
       <name>jdito</name>
+      <contentProcess>%aditoprj%/entity/WorkflowInstance_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
       <recordFieldMappings>
         <jDitoRecordFieldMapping>
           <name>UID.value</name>
diff --git a/entity/WorkflowInstance_entity/recordcontainers/jdito/contentProcess.js b/entity/WorkflowInstance_entity/recordcontainers/jdito/contentProcess.js
new file mode 100644
index 0000000000..221a1a8737
--- /dev/null
+++ b/entity/WorkflowInstance_entity/recordcontainers/jdito/contentProcess.js
@@ -0,0 +1,7 @@
+import("system.vars");
+import("system.workflow");
+
+var workflowDefId = vars.get("$param.WorkflowDefinitionId_param");
+var loadConfig = workflow.createConfigForLoadingProcessInstances()
+    .processDefinitionId(workflowDefId);
+var wfInstances = workflow.getProcessInstances(loadConfig);
\ No newline at end of file
diff --git a/neonView/WorkflowDefinitionPreview_view/WorkflowDefinitionPreview_view.aod b/neonView/WorkflowDefinitionPreview_view/WorkflowDefinitionPreview_view.aod
index 98ff813a0d..855a0bceb7 100644
--- a/neonView/WorkflowDefinitionPreview_view/WorkflowDefinitionPreview_view.aod
+++ b/neonView/WorkflowDefinitionPreview_view/WorkflowDefinitionPreview_view.aod
@@ -14,5 +14,20 @@
       <subtitleField>CATEGORY</subtitleField>
       <entityField>#ENTITY</entityField>
     </cardViewTemplate>
+    <genericViewTemplate>
+      <name>Generic</name>
+      <showDrawer v="true" />
+      <entityField>#ENTITY</entityField>
+      <fields>
+        <entityFieldLink>
+          <name>9ae7bada-afb2-48d4-9aa0-b2bd5bd17379</name>
+          <entityField>ISACTIVE</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>d31118d7-fc96-4126-80f5-4336da434170</name>
+          <entityField>VERSION</entityField>
+        </entityFieldLink>
+      </fields>
+    </genericViewTemplate>
   </children>
 </neonView>
-- 
GitLab