From 475f1e54119087412e4f98d83c8c55e57116ec94 Mon Sep 17 00:00:00 2001
From: "j.goderbauer" <j.goderbauer@adito.de>
Date: Mon, 11 Feb 2019 17:24:08 +0100
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?=
 =?UTF-8?q?=201032312][Keywords=20f=C3=BCr=20bestehende=20Module=20anlegen?=
 =?UTF-8?q?]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../valueProcess.js                           |  2 +-
 .../entityfields/image/valueProcess.js        |  2 +-
 .../entityfields/image/valueProcess.js        |  2 +-
 .../source_id/possibleItemsProcess.js         |  2 +-
 process/Keyword_lib/process.js                | 26 +++++++++++++++++--
 process/Org_lib/process.js                    |  2 +-
 6 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/entity/Contract_entity/entityfields/contractcode_display_fieldgroup/valueProcess.js b/entity/Contract_entity/entityfields/contractcode_display_fieldgroup/valueProcess.js
index 7950e01efeb..97ab0469059 100644
--- a/entity/Contract_entity/entityfields/contractcode_display_fieldgroup/valueProcess.js
+++ b/entity/Contract_entity/entityfields/contractcode_display_fieldgroup/valueProcess.js
@@ -5,4 +5,4 @@ import("Keyword_lib");
 var cType = vars.get("$field.CONTRACTTYPE");
 var cCode = vars.get("$field.CONTRACTCODE");
 
-result.string(KeywordUtils.getViewValue("CONTRACT.CONTRACTTYPE", cType) + " : " + cCode);
\ No newline at end of file
+result.string(KeywordUtils.getViewValue($KeywordRegistry.get.ContractType, cType) + " : " + cCode);
\ No newline at end of file
diff --git a/entity/Contract_entity/entityfields/image/valueProcess.js b/entity/Contract_entity/entityfields/image/valueProcess.js
index 722fa96502a..0219288c0b8 100644
--- a/entity/Contract_entity/entityfields/image/valueProcess.js
+++ b/entity/Contract_entity/entityfields/image/valueProcess.js
@@ -2,4 +2,4 @@ import("system.vars");
 import("system.result");
 import("Keyword_lib");
 
-result.string("TEXT:" + KeywordUtils.getViewValue("CONTRACT.CONTRACTTYPE", vars.getString("$field.CONTRACTTYPE")) );
\ No newline at end of file
+result.string("TEXT:" + KeywordUtils.getViewValue($KeywordRegistry.get.ContractType, vars.getString("$field.CONTRACTTYPE")) );
\ No newline at end of file
diff --git a/entity/Order_entity/entityfields/image/valueProcess.js b/entity/Order_entity/entityfields/image/valueProcess.js
index ccc48faa05c..b90c29afbfb 100644
--- a/entity/Order_entity/entityfields/image/valueProcess.js
+++ b/entity/Order_entity/entityfields/image/valueProcess.js
@@ -2,4 +2,4 @@ import("system.vars");
 import("system.result");
 import("Keyword_lib");
 
-result.string("TEXT:" + KeywordUtils.getViewValue($KeywordRegistry.get.SalesprojectState, vars.getString("$field.STATUS")) );
\ No newline at end of file
+result.string("TEXT:" + KeywordUtils.getViewValue($KeywordRegistry.get.SalesorderState, vars.getString("$field.STATUS")) );
\ No newline at end of file
diff --git a/entity/Prod2prod_entity/entityfields/source_id/possibleItemsProcess.js b/entity/Prod2prod_entity/entityfields/source_id/possibleItemsProcess.js
index 4be8d5f270a..72863229e5c 100644
--- a/entity/Prod2prod_entity/entityfields/source_id/possibleItemsProcess.js
+++ b/entity/Prod2prod_entity/entityfields/source_id/possibleItemsProcess.js
@@ -23,7 +23,7 @@ var prods = db.table("select PRODUCTID, GROUPCODEID, PRODUCTNAME, PRODUCTCODE fr
 var res = [];
 for(var i = 0; i < prods.length; i++)
 {
-    res.push([prods[i][0], KeywordUtils.getViewValue("GROUPCODE", prods[i][1]) + " / " + prods[i][2] + " / " + prods[i][3]]);
+    res.push([prods[i][0], KeywordUtils.getViewValue($KeywordRegistry.get.ProductGroupcode, prods[i][1]) + " / " + prods[i][2] + " / " + prods[i][3]]);
 }
 
 result.object(res);
\ No newline at end of file
diff --git a/process/Keyword_lib/process.js b/process/Keyword_lib/process.js
index 2ecca3916bb..504d19a735a 100644
--- a/process/Keyword_lib/process.js
+++ b/process/Keyword_lib/process.js
@@ -142,8 +142,30 @@ KeywordUtils.getResolvedTitleSqlPart = function(pContainerName, pDbFieldName, pL
      * }
      */
     KeywordUtils.getViewValue = function(keywordType, key){
-        var k = KeywordUtils.createKeyword(keywordType);
-        return k.getPropForKey(key, "name") || "";
+        //temporary solution: support old (=legacy) and new keyword logic
+        if ($KeywordRegistry.get[keywordType])
+        {
+            //new keyword logic
+            /*select AB_KEYWORD_ENTRY.TITLE
+            from AB_KEYWORD_ENTRY
+            where AB_KEYWORD_ENTRY.CONTAINER = '' and KEYID = ''*/
+            var sql = SqlCondition.begin()
+                                   .andPrepare("AB_KEYWORD_ENTRY.CONTAINER", keywordType)
+                                   .andPrepare("AB_KEYWORD_ENTRY.KEYID", key)
+                                   .buildSql("select AB_KEYWORD_ENTRY.TITLE from AB_KEYWORD_ENTRY");
+            var originalTitle = db.cell(sql);
+            if (originalTitle == "")
+                return "";
+            
+            var translatedTitle = translate.text(originalTitle);
+            return translatedTitle;
+        }
+        else
+        {
+            //legacy keyword logic
+            var k = KeywordUtils.createKeyword(keywordType);
+            return k.getPropForKey(key, "name") || "";
+        }
     }
 
     /**
diff --git a/process/Org_lib/process.js b/process/Org_lib/process.js
index 169a00701e6..8cf4ce4af54 100644
--- a/process/Org_lib/process.js
+++ b/process/Org_lib/process.js
@@ -151,7 +151,7 @@ OrgUtils.openOrgReport = function(pOrgId)
     
     taskData.forEach(function (row) 
     {
-        row[2] = KeywordUtils.getViewValue("TASK.STATUS", row[2]);
+        row[2] = KeywordUtils.getViewValue($KeywordRegistry.get.TaskStatus, row[2]);
         _joinArrayVals(row, 3, 2); //join FIRSTNAME and LASTNAME together
     });
     taskData = ReportData.begin(["SUBJECT", "INFOTEXT", "STATUS", "RESPONSIBLE"]).add(taskData);
-- 
GitLab