From 53d3667b627187514f956267502f55c5c6517208 Mon Sep 17 00:00:00 2001
From: Markus Escher <m.escher@adito.de>
Date: Mon, 10 Dec 2018 17:32:00 +0100
Subject: [PATCH] add Multilookup for Product

---
 entity/Product_entity/Product_entity.aod      | 20 ++++++-------------
 .../entityfields/relation_id/valueProcess.js  |  9 ---------
 entity/Relation_entity/Relation_entity.aod    |  9 +++++++++
 entity/Relation_entity/titleProcess.js        |  8 ++++++++
 .../ProductPreview_view.aod                   |  8 ++++++--
 .../RelationLookup_view.aod                   |  6 ++++++
 6 files changed, 35 insertions(+), 25 deletions(-)
 delete mode 100644 entity/Product_entity/entityfields/relation_id/valueProcess.js
 create mode 100644 entity/Relation_entity/titleProcess.js

diff --git a/entity/Product_entity/Product_entity.aod b/entity/Product_entity/Product_entity.aod
index 09a5112e0e..ab34901515 100644
--- a/entity/Product_entity/Product_entity.aod
+++ b/entity/Product_entity/Product_entity.aod
@@ -238,7 +238,6 @@
       <title>Developer</title>
       <linkedContextProcess>%aditoprj%/entity/Product_entity/entityfields/relation_id/linkedContextProcess.js</linkedContextProcess>
       <outgoingField>ProductRelation_dfo</outgoingField>
-      <valueProcess>%aditoprj%/entity/Product_entity/entityfields/relation_id/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>RELATION_ORG_ID</name>
@@ -267,26 +266,19 @@
       <onDBDelete>%aditoprj%/entity/Product_entity/recordcontainers/db/onDBDelete.js</onDBDelete>
       <linkInformation>
         <linkInformation>
-          <name>219bb2ab-3c6f-475f-a2b4-0d3e48b16b8f</name>
+          <name>551ab91d-6a97-4307-bd02-628cdfdee274</name>
           <tableName>PRODUCT</tableName>
           <primaryKey>PRODUCTID</primaryKey>
           <isUIDTable v="true" />
           <readonly v="false" />
         </linkInformation>
         <linkInformation>
-          <name>478598a4-3130-4b0c-ba8d-14b67f003ee5</name>
+          <name>4518b616-7213-4341-9170-f95a76d1e2bb</name>
           <tableName>RELATION</tableName>
           <primaryKey>RELATIONID</primaryKey>
           <isUIDTable v="false" />
           <readonly v="true" />
         </linkInformation>
-        <linkInformation>
-          <name>3800cc08-4ab5-4b9a-a200-993c990b7906</name>
-          <tableName>ORG</tableName>
-          <primaryKey>ORGID</primaryKey>
-          <isUIDTable v="false" />
-          <readonly v="true" />
-        </linkInformation>
       </linkInformation>
       <recordFieldMappings>
         <dbRecordFieldMapping>
@@ -309,10 +301,6 @@
           <name>MINSTOCK.value</name>
           <recordfield>PRODUCT.MINSTOCK</recordfield>
         </dbRecordFieldMapping>
-        <dbRecordFieldMapping>
-          <name>RELATION_ID.value</name>
-          <recordfield>PRODUCT.RELATION_ID</recordfield>
-        </dbRecordFieldMapping>
         <dbRecordFieldMapping>
           <name>PRODUCTCODE.value</name>
           <recordfield>PRODUCT.PRODUCTCODE</recordfield>
@@ -355,6 +343,10 @@
         </dbRecordFieldMapping>
         <dbRecordFieldMapping>
           <name>RELATION_ID.displayValue</name>
+          <recordfield>RELATION.RELATIONID</recordfield>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>RELATION_ID.value</name>
           <recordfield>PRODUCT.RELATION_ID</recordfield>
         </dbRecordFieldMapping>
       </recordFieldMappings>
diff --git a/entity/Product_entity/entityfields/relation_id/valueProcess.js b/entity/Product_entity/entityfields/relation_id/valueProcess.js
deleted file mode 100644
index 7e309f23c0..0000000000
--- a/entity/Product_entity/entityfields/relation_id/valueProcess.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import("system.vars");
-import("system.result");
-import("system.neon");
-
-if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW)
-{
-    if(vars.exists("$param.relationId_param") && vars.get("$param.relationId_param"))
-        result.string(vars.getString("$param.relationId_param"));    
-}
diff --git a/entity/Relation_entity/Relation_entity.aod b/entity/Relation_entity/Relation_entity.aod
index 6eb5c5ac95..58ce763140 100644
--- a/entity/Relation_entity/Relation_entity.aod
+++ b/entity/Relation_entity/Relation_entity.aod
@@ -2,6 +2,7 @@
 <entity 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/entity/1.1.0">
   <name>Relation_entity</name>
   <majorModelMode>DISTRIBUTED</majorModelMode>
+  <titleProcess>%aditoprj%/entity/Relation_entity/titleProcess.js</titleProcess>
   <recordContainer>db</recordContainer>
   <entityFields>
     <entityIncomingField>
@@ -99,6 +100,10 @@ See RelationUtils.getRelationTypeByPersOrg for possible values</description>
       <name>PERS_FIRSTNAME</name>
       <title>Firstname</title>
     </entityField>
+    <entityField>
+      <name>PERS_LASTNAME</name>
+      <title>Lastname</title>
+    </entityField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
@@ -184,6 +189,10 @@ See RelationUtils.getRelationTypeByPersOrg for possible values</description>
           <name>PERS_FIRSTNAME.value</name>
           <recordfield>PERS.FIRSTNAME</recordfield>
         </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>PERS_LASTNAME.value</name>
+          <recordfield>PERS.LASTNAME</recordfield>
+        </dbRecordFieldMapping>
       </recordFieldMappings>
     </dbRecordContainer>
   </recordContainers>
diff --git a/entity/Relation_entity/titleProcess.js b/entity/Relation_entity/titleProcess.js
new file mode 100644
index 0000000000..c11d77e909
--- /dev/null
+++ b/entity/Relation_entity/titleProcess.js
@@ -0,0 +1,8 @@
+import("system.vars");
+import("system.result");
+
+if(vars.get("$field.PERS_FIRSTNAME")) {
+    result.string(vars.get("$field.PERS_FIRSTNAME") + " " + vars.get("$field.PERS_LASTNAME"));
+} else {
+    result.string(vars.get("$field.ORG_NAME"));
+}
diff --git a/neonView/ProductPreview_view/ProductPreview_view.aod b/neonView/ProductPreview_view/ProductPreview_view.aod
index 94a1c90ba1..b9f47de028 100644
--- a/neonView/ProductPreview_view/ProductPreview_view.aod
+++ b/neonView/ProductPreview_view/ProductPreview_view.aod
@@ -21,8 +21,8 @@
       <entityField>#ENTITY</entityField>
       <fields>
         <entityFieldLink>
-          <name>00594c0e-6641-4f6d-9717-1eee2678ad5d</name>
-          <entityField>PRODUCTNAME</entityField>
+          <name>c47d3f86-867d-4bc4-bcc3-6e22ff8efa6d</name>
+          <entityField>GROUPCODEID</entityField>
         </entityFieldLink>
         <entityFieldLink>
           <name>bd8e7e33-6fc6-48fe-b9be-931383f4d859</name>
@@ -48,6 +48,10 @@
           <name>ba604dc5-06b2-44f2-a9b3-c4c3adb9f8f8</name>
           <entityField>MINSTOCK</entityField>
         </entityFieldLink>
+        <entityFieldLink>
+          <name>2ba11e8f-6636-40a9-a078-672f34591162</name>
+          <entityField>#INCOMING</entityField>
+        </entityFieldLink>
       </fields>
     </genericViewTemplate>
     <neonViewReference>
diff --git a/neonView/RelationLookup_view/RelationLookup_view.aod b/neonView/RelationLookup_view/RelationLookup_view.aod
index bac028eedb..0bb4bfe20d 100644
--- a/neonView/RelationLookup_view/RelationLookup_view.aod
+++ b/neonView/RelationLookup_view/RelationLookup_view.aod
@@ -20,6 +20,12 @@
           <name>814b3f18-106a-443e-8415-762669f862e6</name>
           <entityField>PERS_FIRSTNAME</entityField>
         </neonTableColumn>
+        <neonTableColumn>
+          <name>4b05d812-aa6c-49a5-afa3-ea5cd99560ef</name>
+          <entityField>PERS_LASTNAME</entityField>
+          <width v="75" />
+          <expandRatio v="100" />
+        </neonTableColumn>
       </columns>
     </tableViewTemplate>
   </children>
-- 
GitLab