From eccd27be13a0ba91c88503fcff63b0b2e653852c Mon Sep 17 00:00:00 2001
From: Sophia Leierseder <s.leierseder@adito.de>
Date: Thu, 25 Apr 2019 13:27:48 +0200
Subject: [PATCH] basics limitation of attachment-lookup

---
 .../DocumentTemplateLink_entity.aod                  | 10 ++++++++++
 .../documenttemplatetype_param/valueProcess.js       |  5 -----
 .../documenttemplate_id_child/stateProcess.js        | 12 +++++++-----
 .../documenttemplate_id_child/valueProcess.js        |  8 --------
 .../recordcontainers/db/conditionProcess.js          | 12 +++++++++++-
 .../DocumentTemplate_entity.aod                      |  8 ++++++++
 .../links/children/type_param/valueProcess.js        |  4 ++++
 7 files changed, 40 insertions(+), 19 deletions(-)
 create mode 100644 entity/DocumentTemplate_entity/entityfields/links/children/type_param/valueProcess.js

diff --git a/entity/DocumentTemplateLink_entity/DocumentTemplateLink_entity.aod b/entity/DocumentTemplateLink_entity/DocumentTemplateLink_entity.aod
index 21fbf86b1a..8f3f448246 100644
--- a/entity/DocumentTemplateLink_entity/DocumentTemplateLink_entity.aod
+++ b/entity/DocumentTemplateLink_entity/DocumentTemplateLink_entity.aod
@@ -81,8 +81,18 @@
           <name>DocumentId_param</name>
           <triggerRecalculation v="true" />
         </entityParameter>
+        <entityParameter>
+          <name>Type_param</name>
+          <triggerRecalculation v="true" />
+        </entityParameter>
       </children>
     </entityProvider>
+    <entityParameter>
+      <name>Type_param</name>
+      <expose v="true" />
+      <triggerRecalculation v="false" />
+      <description>PARAMETER</description>
+    </entityParameter>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/DocumentTemplateLink_entity/entityfields/attachments/children/documenttemplatetype_param/valueProcess.js b/entity/DocumentTemplateLink_entity/entityfields/attachments/children/documenttemplatetype_param/valueProcess.js
index 68704076d0..e69de29bb2 100644
--- a/entity/DocumentTemplateLink_entity/entityfields/attachments/children/documenttemplatetype_param/valueProcess.js
+++ b/entity/DocumentTemplateLink_entity/entityfields/attachments/children/documenttemplatetype_param/valueProcess.js
@@ -1,5 +0,0 @@
-import("system.vars");
-import("system.result");
-if(vars.getString("$field.TYPE") == "ATT"){
-    result.string("$field.DOCUMENTTEMPLATEID");
-}
\ 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 1e6f365bf2..e2ebc8de0a 100644
--- a/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/stateProcess.js
+++ b/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/stateProcess.js
@@ -4,8 +4,10 @@ import("system.result");
 import("system.vars");
 import("system.db");
 
-//var parenttype = db.cell("select TYPE from DOCUMENTTEMPLATE");
-//
-//
-//if(parenttype == "MAI")
-//    result.string("DISABLED");
\ No newline at end of file
+var parenttype = vars.get("$param.Type_param");
+logging.log(parenttype);
+
+if(vars.exists(parenttype) && paraenttype != null && parenttype != "MAI"){
+    result.object(neon.COMPONENTSTATE_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
index ce2998f625..e69de29bb2 100644
--- a/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/valueProcess.js
+++ b/entity/DocumentTemplateLink_entity/entityfields/documenttemplate_id_child/valueProcess.js
@@ -1,8 +0,0 @@
-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/DocumentTemplateLink_entity/recordcontainers/db/conditionProcess.js b/entity/DocumentTemplateLink_entity/recordcontainers/db/conditionProcess.js
index d1d7f21be9..ae6a038872 100644
--- a/entity/DocumentTemplateLink_entity/recordcontainers/db/conditionProcess.js
+++ b/entity/DocumentTemplateLink_entity/recordcontainers/db/conditionProcess.js
@@ -7,4 +7,14 @@ var cond = SqlCondition.begin()
                        .andPrepareVars("DOCUMENTTEMPLATELINK.DOCUMENTTEMPLATE_ID_PARENT", "$param.DocumentId_param");
 
 //TODO: use a preparedCondition when available #1030812 #1034026
-result.string(db.translateCondition(cond.build("1 = 0")));
\ No newline at end of file
+result.string(db.translateCondition(cond.build("1 = 0")));
+
+//if(vars.exists("$param.Type_param") && vars.get("$param.Type_param") != null && vars.get("$param.Type_param") == "ATT"){
+//    
+//    var cond = SqlCondition.begin()
+//                       .andPrepare("DOCUMENTTEMPLATELINK.ATTACHMENT_TYPE", type)
+//                       .andPrepareVars("DOCUMENTTEMPLATELINK.DOCUMENTTEMPLATE_ID_PARENT", docId)
+//                       .build();
+//                       
+//    result.string(db.translateCondition(cond));
+//}
\ No newline at end of file
diff --git a/entity/DocumentTemplate_entity/DocumentTemplate_entity.aod b/entity/DocumentTemplate_entity/DocumentTemplate_entity.aod
index 87e643c5d7..3fb259e5a8 100644
--- a/entity/DocumentTemplate_entity/DocumentTemplate_entity.aod
+++ b/entity/DocumentTemplate_entity/DocumentTemplate_entity.aod
@@ -208,6 +208,14 @@
         <entityParameter>
           <name>DocumentId_param</name>
           <valueProcess>%aditoprj%/entity/DocumentTemplate_entity/entityfields/links/children/documentid_param/valueProcess.js</valueProcess>
+          <expose v="true" />
+          <triggerRecalculation v="true" />
+        </entityParameter>
+        <entityParameter>
+          <name>Type_param</name>
+          <valueProcess>%aditoprj%/entity/DocumentTemplate_entity/entityfields/links/children/type_param/valueProcess.js</valueProcess>
+          <expose v="true" />
+          <triggerRecalculation v="true" />
         </entityParameter>
       </children>
     </entityConsumer>
diff --git a/entity/DocumentTemplate_entity/entityfields/links/children/type_param/valueProcess.js b/entity/DocumentTemplate_entity/entityfields/links/children/type_param/valueProcess.js
new file mode 100644
index 0000000000..e133265a13
--- /dev/null
+++ b/entity/DocumentTemplate_entity/entityfields/links/children/type_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.TYPE"));
\ No newline at end of file
-- 
GitLab