From 06778078ff25b0fa1a56e2f36dcda6065578683a Mon Sep 17 00:00:00 2001
From: Sophia Leierseder <s.leierseder@adito.de>
Date: Thu, 25 Apr 2019 07:54:25 +0200
Subject: [PATCH] DocumentTemplate Parameter changes

---
 .../DocumentTemplateLink_entity.aod                 | 13 +++++++------
 .../children/doctemptype_param/valueProcess.js      |  1 -
 .../documenttemplate_id_child/stateProcess.js       |  2 --
 .../documenttemplate_id_child/valueProcess.js       |  8 ++++++++
 .../DocumentTemplate_entity.aod                     |  9 ++++++++-
 .../documenttemplatetype_param/valueProcess.js      |  6 ++++++
 6 files changed, 29 insertions(+), 10 deletions(-)
 delete mode 100644 entity/DocumentTemplateLink_entity/entityfields/attachments/children/doctemptype_param/valueProcess.js
 create mode 100644 entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/valueProcess.js
 create mode 100644 entity/DocumentTemplate_entity/entityfields/attachments/children/documenttemplatetype_param/valueProcess.js

diff --git a/entity/DocumentTemplateLink_entity/DocumentTemplateLink_entity.aod b/entity/DocumentTemplateLink_entity/DocumentTemplateLink_entity.aod
index d14eead263..1946ab3340 100644
--- a/entity/DocumentTemplateLink_entity/DocumentTemplateLink_entity.aod
+++ b/entity/DocumentTemplateLink_entity/DocumentTemplateLink_entity.aod
@@ -39,6 +39,7 @@
       <name>DOCUMENTTEMPLATE_ID_CHILD</name>
       <consumer>Attachments</consumer>
       <stateProcess>%aditoprj%/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/stateProcess.js</stateProcess>
+      <valueProcess>%aditoprj%/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/valueProcess.js</valueProcess>
       <displayValueProcess>%aditoprj%/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/displayValueProcess.js</displayValueProcess>
     </entityField>
     <entityParameter>
@@ -55,12 +56,6 @@
         <entityName>DocumentTemplate_entity</entityName>
         <fieldName>Attachments</fieldName>
       </dependency>
-      <children>
-        <entityParameter>
-          <name>DocTempType_param</name>
-          <valueProcess>%aditoprj%/entity/DocumentTemplateLink_entity/entityfields/attachments/children/doctemptype_param/valueProcess.js</valueProcess>
-        </entityParameter>
-      </children>
     </entityConsumer>
     <entityProvider>
       <name>Links</name>
@@ -75,6 +70,12 @@
           <isConsumer v="false" />
         </entityDependency>
       </dependencies>
+      <children>
+        <entityParameter>
+          <name>DocumentId_param</name>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+      </children>
     </entityProvider>
   </entityFields>
   <recordContainers>
diff --git a/entity/DocumentTemplateLink_entity/entityfields/attachments/children/doctemptype_param/valueProcess.js b/entity/DocumentTemplateLink_entity/entityfields/attachments/children/doctemptype_param/valueProcess.js
deleted file mode 100644
index 98a7b42953..0000000000
--- a/entity/DocumentTemplateLink_entity/entityfields/attachments/children/doctemptype_param/valueProcess.js
+++ /dev/null
@@ -1 +0,0 @@
-//TODO: Es sollen hier nur die Anhänge gelistet werden! 
\ No newline at end of file
diff --git a/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/stateProcess.js b/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/stateProcess.js
index c04409ebc2..d06fed7cef 100644
--- a/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/stateProcess.js
+++ b/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/stateProcess.js
@@ -6,8 +6,6 @@ import("system.db");
 
 var parenttype = db.cell("select TYPE from DOCUMENTTEMPLATE");
 
-logging.log(parenttype);
-
 //
 //if(parenttype == "MAI")
 //    result.string("DISABLED");
\ No newline at end of file
diff --git a/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/valueProcess.js b/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/valueProcess.js
new file mode 100644
index 0000000000..75ec01b1f8
--- /dev/null
+++ b/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/valueProcess.js
@@ -0,0 +1,8 @@
+import("system.logging");
+import("system.result");
+import("system.vars");
+
+//if (vars.exists("$param.DocumentTemplateType_param")) 
+//{
+//    result.string(vars.get("$param.DocumentTemplateType_param"));
+//}
diff --git a/entity/DocumentTemplate_entity/DocumentTemplate_entity.aod b/entity/DocumentTemplate_entity/DocumentTemplate_entity.aod
index 202f0d096e..2b08a4cfca 100644
--- a/entity/DocumentTemplate_entity/DocumentTemplate_entity.aod
+++ b/entity/DocumentTemplate_entity/DocumentTemplate_entity.aod
@@ -185,7 +185,7 @@
       <name>DocumentTemplateType_param</name>
       <expose v="true" />
       <triggerRecalculation v="true" />
-      <mandatory v="true" />
+      <mandatory v="false" />
       <description>PARAMETER</description>
     </entityParameter>
     <entityProvider>
@@ -201,6 +201,13 @@
           <isConsumer v="false" />
         </entityDependency>
       </dependencies>
+      <children>
+        <entityParameter>
+          <name>DocumentTemplateType_param</name>
+          <valueProcess>%aditoprj%/entity/DocumentTemplate_entity/entityfields/attachments/children/documenttemplatetype_param/valueProcess.js</valueProcess>
+          <mandatory v="false" />
+        </entityParameter>
+      </children>
     </entityProvider>
     <entityConsumer>
       <name>Links</name>
diff --git a/entity/DocumentTemplate_entity/entityfields/attachments/children/documenttemplatetype_param/valueProcess.js b/entity/DocumentTemplate_entity/entityfields/attachments/children/documenttemplatetype_param/valueProcess.js
new file mode 100644
index 0000000000..0987589736
--- /dev/null
+++ b/entity/DocumentTemplate_entity/entityfields/attachments/children/documenttemplatetype_param/valueProcess.js
@@ -0,0 +1,6 @@
+import("system.result");
+import("system.vars");
+
+if(vars.getString("$field.TYPE") == "ATT"){
+    result.string("$field.DOCUMENTTEMPLATEID");
+}
\ No newline at end of file
-- 
GitLab