From 792f4f2843c56e84d21f1177a49de7d3753f39e0 Mon Sep 17 00:00:00 2001
From: Tobias Feldmann <t.feldmann@adito.de>
Date: Mon, 29 Jul 2019 14:49:41 +0200
Subject: [PATCH] Order in 360Degree

---
 entity/360Degree_entity/360Degree_entity.aod  |  8 +++++++
 .../children/neworder/onActionProcess.js      |  4 ++++
 .../children/neworder/stateProcess.js         | 22 +++++++++++++++++++
 .../children/objecttype_param/valueProcess.js |  2 +-
 process/Context_lib/process.js                |  4 ++--
 process/KeywordRegistry_basic/process.js      |  6 +++++
 process/Order_lib/process.js                  |  2 +-
 7 files changed, 44 insertions(+), 4 deletions(-)
 create mode 100644 entity/360Degree_entity/entityfields/newmodule/children/neworder/onActionProcess.js
 create mode 100644 entity/360Degree_entity/entityfields/newmodule/children/neworder/stateProcess.js

diff --git a/entity/360Degree_entity/360Degree_entity.aod b/entity/360Degree_entity/360Degree_entity.aod
index 64aebbbac9..8667de2368 100644
--- a/entity/360Degree_entity/360Degree_entity.aod
+++ b/entity/360Degree_entity/360Degree_entity.aod
@@ -142,6 +142,13 @@
           <onActionProcess>%aditoprj%/entity/360Degree_entity/entityfields/newmodule/children/newsupportticket/onActionProcess.js</onActionProcess>
           <iconId>VAADIN:QUESTION</iconId>
         </entityActionField>
+        <entityActionField>
+          <name>newOrder</name>
+          <title>Order</title>
+          <onActionProcess>%aditoprj%/entity/360Degree_entity/entityfields/newmodule/children/neworder/onActionProcess.js</onActionProcess>
+          <iconId>VAADIN:DOLLAR</iconId>
+          <stateProcess>%aditoprj%/entity/360Degree_entity/entityfields/newmodule/children/neworder/stateProcess.js</stateProcess>
+        </entityActionField>
       </children>
     </entityActionGroup>
     <entityField>
@@ -186,6 +193,7 @@
         </jDitoRecordFieldMapping>
         <jDitoRecordFieldMapping>
           <name>ACTIVE.value</name>
+          <isFilterable v="true" />
         </jDitoRecordFieldMapping>
       </recordFieldMappings>
     </jDitoRecordContainer>
diff --git a/entity/360Degree_entity/entityfields/newmodule/children/neworder/onActionProcess.js b/entity/360Degree_entity/entityfields/newmodule/children/neworder/onActionProcess.js
new file mode 100644
index 0000000000..5fa0055caa
--- /dev/null
+++ b/entity/360Degree_entity/entityfields/newmodule/children/neworder/onActionProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("Order_lib");
+
+OrderUtils.createNewOrder(null, vars.getString("$param.ObjectRowId_param"));
\ No newline at end of file
diff --git a/entity/360Degree_entity/entityfields/newmodule/children/neworder/stateProcess.js b/entity/360Degree_entity/entityfields/newmodule/children/neworder/stateProcess.js
new file mode 100644
index 0000000000..1c2b2b9123
--- /dev/null
+++ b/entity/360Degree_entity/entityfields/newmodule/children/neworder/stateProcess.js
@@ -0,0 +1,22 @@
+import("system.vars");
+import("system.neon");
+import("system.result");
+
+var contextList = JSON.parse(vars.getString("$param.ObjectType_param"));
+if (contextList)
+{
+    var found = false;
+    contextList.forEach(function (context) 
+    {
+        if(context == "Order")
+            found = true;        
+    });
+    if(found)
+        result.string(neon.COMPONENTSTATE_AUTO);
+    else
+        result.string(neon.COMPONENTSTATE_INVISIBLE);
+}
+else
+{
+    result.string(neon.COMPONENTSTATE_INVISIBLE);
+}
\ No newline at end of file
diff --git a/entity/360Degree_entity/entityfields/organisationobjects/children/objecttype_param/valueProcess.js b/entity/360Degree_entity/entityfields/organisationobjects/children/objecttype_param/valueProcess.js
index 357494dd61..187ce75fa9 100644
--- a/entity/360Degree_entity/entityfields/organisationobjects/children/objecttype_param/valueProcess.js
+++ b/entity/360Degree_entity/entityfields/organisationobjects/children/objecttype_param/valueProcess.js
@@ -1,4 +1,4 @@
 import("system.vars");
 import("system.result");
 
-result.object(["Salesproject", "Offer", "Contract", "Campaign", "Order"]);
\ No newline at end of file
+result.object(["Salesproject", "Offer", "Order", "Contract", "Campaign", "Order"]);
\ No newline at end of file
diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js
index 295ccaca31..50aeb817ca 100644
--- a/process/Context_lib/process.js
+++ b/process/Context_lib/process.js
@@ -428,7 +428,7 @@ ContextUtils.getSelectMap  = function()
                                      .setContactIdField("CONTACT_ID")
                                      .setCreationDateField("OFFERDATE")
                                      .setStateField("STATUS")
-                                     .setActiveStates(["70d27a1b-7233-481d-826f-01a13a4bb0b2", "5134153d-2e18-452f-ab35-7a52f1aee7d1", "e5d6b5a4-7576-440f-8332-bc40147c0335"])
+                                     .setActiveStates([$KeywordRegistry.offerStatus$open, $KeywordRegistry.offerStatus$checked, $KeywordRegistry.offerStatus$sent])
             ,"Order": ContextSelector.create("SALESORDER", "SALESORDERID")
                                      .setTitleExpression(maskingUtils.concat([
                                                         "'" + translate.text("Order") + "'",
@@ -440,7 +440,7 @@ ContextUtils.getSelectMap  = function()
                                      .setContactIdField("CONTACT_ID")
                                      .setCreationDateField("SALESORDERDATE")
                                      .setStateField("STATUS")
-                                     .setActiveStates([])
+                                     .setActiveStates([$KeywordRegistry.salesorderState$checked, $KeywordRegistry.salesorderState$sent])
             ,"Product": ContextSelector.create("PRODUCT", "PRODUCTID")
                                        .setTitleExpression(maskingUtils.concat([
                                             "PRODUCTCODE",
diff --git a/process/KeywordRegistry_basic/process.js b/process/KeywordRegistry_basic/process.js
index 572e314759..d6b3756eb7 100644
--- a/process/KeywordRegistry_basic/process.js
+++ b/process/KeywordRegistry_basic/process.js
@@ -79,7 +79,13 @@ $KeywordRegistry.quantityUnit$pieces = function(){return $KeywordRegistry._autoP
 
 $KeywordRegistry.MemberRole = function(){return "MemberRole";};
 $KeywordRegistry.salesprojectSource = function(){return "SalesprojectSource";};
+
 $KeywordRegistry.salesorderState = function(){return "SalesorderState";};
+$KeywordRegistry.salesorderState$checked = function(){return $KeywordRegistry._autoPad("SALORDERSTATCHECK");};
+$KeywordRegistry.salesorderState$sent = function(){return $KeywordRegistry._autoPad("SALORDERSTATSENT");};
+$KeywordRegistry.salesorderState$won = function(){return $KeywordRegistry._autoPad("SALORDERSTATWON");};
+$KeywordRegistry.salesorderState$lost = function(){return $KeywordRegistry._autoPad("SALORDERSTATLOST");};
+
 $KeywordRegistry.salesprojectWonLost = function(){return "SalesprojectWonLost";};
 $KeywordRegistry.stockWarehouse = function(){return "StockWarehouse";};
 $KeywordRegistry.salesprojectProbability = function(){return "SalesprojectProbability";};
diff --git a/process/Order_lib/process.js b/process/Order_lib/process.js
index fe4915c08a..4b7dc1ed1c 100644
--- a/process/Order_lib/process.js
+++ b/process/Order_lib/process.js
@@ -75,7 +75,7 @@ OrderUtils.createNewOrder = function(pSalesprojectId, pRelationId)
     if (pRelationId)
         params["ContactId_param"] = pRelationId;
     
-    neon.openContext("Order", null, neon.OPERATINGSTATE_NEW, params);
+    neon.openContext("Order", null, null, neon.OPERATINGSTATE_NEW, params);
 }
 
 /**
-- 
GitLab