From 9329d6aa2f5b4bb42145ca74ec8cd392e806cec5 Mon Sep 17 00:00:00 2001 From: "m.escher" <m.escher@adito.de> Date: Tue, 4 Dec 2018 09:31:57 +0100 Subject: [PATCH] RecordContainer fix: Prod2prod_entity --- entity/Prod2prod_entity/Prod2prod_entity.aod | 37 +++++++++++++++---- .../recordcontainers/jdito/contentProcess.js | 14 +++++++ .../recordcontainers/jdito/onDelete.js | 4 ++ .../recordcontainers/jdito/onInsert.js | 25 +++++++++++++ .../recordcontainers/jdito/onUpdate.js | 23 ++++++++++++ 5 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js create mode 100644 entity/Prod2prod_entity/recordcontainers/jdito/onDelete.js create mode 100644 entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js create mode 100644 entity/Prod2prod_entity/recordcontainers/jdito/onUpdate.js diff --git a/entity/Prod2prod_entity/Prod2prod_entity.aod b/entity/Prod2prod_entity/Prod2prod_entity.aod index ce05f40bd6..5ded60f6ad 100644 --- a/entity/Prod2prod_entity/Prod2prod_entity.aod +++ b/entity/Prod2prod_entity/Prod2prod_entity.aod @@ -23,6 +23,15 @@ <onInsert>%aditoprj%/entity/Prod2prod_entity/onInsert.js</onInsert> <onUpdate>%aditoprj%/entity/Prod2prod_entity/onUpdate.js</onUpdate> <onDelete>%aditoprj%/entity/Prod2prod_entity/onDelete.js</onDelete> + <recordContainer>jdito</recordContainer> + <linkInformation> + <linkInformation> + <name>96c9cc1a-26ee-4cc3-8e83-330420fc2c60</name> + <tableName>PROD2PROD</tableName> + <primaryKey>PROD2PRODID</primaryKey> + <isUIDTable v="true" /> + </linkInformation> + </linkInformation> <entityFields> <entityIncomingField> <name>#INCOMING</name> @@ -130,12 +139,24 @@ <valueProcess>%aditoprj%/entity/Prod2prod_entity/entityfields/prod2prodid/valueProcess.js</valueProcess> </entityField> </entityFields> - <linkInformation> - <linkInformation> - <name>96c9cc1a-26ee-4cc3-8e83-330420fc2c60</name> - <tableName>PROD2PROD</tableName> - <primaryKey>PROD2PRODID</primaryKey> - <isUIDTable v="true" /> - </linkInformation> - </linkInformation> + <recordContainers> + <jDitoRecordContainer> + <name>jdito</name> + <jDitoRecordAlias>Data_alias</jDitoRecordAlias> + <contentProcess>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js</contentProcess> + <onInsert>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js</onInsert> + <onUpdate>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/onUpdate.js</onUpdate> + <onDelete>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/onDelete.js</onDelete> + <recordFields> + <element>UID.value</element> + <element>PARENTID.value</element> + <element>PROD2PRODID.value</element> + <element>DEST_ID.value</element> + <element>SOURCE_ID.value</element> + <element>QUANTITY.value</element> + <element>OPTIONAL.value</element> + <element>TAKEPRICE.value</element> + </recordFields> + </jDitoRecordContainer> + </recordContainers> </entity> diff --git a/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js b/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js new file mode 100644 index 0000000000..912ab1f560 --- /dev/null +++ b/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js @@ -0,0 +1,14 @@ +import("system.result"); +import("system.vars"); +import("system.db"); +import("system.util"); +import("Product_lib"); + +var prodid = vars.exists("$param.ProductId_param") + && vars.get("$param.ProductId_param") != null ? vars.get("$param.ProductId_param") : ""; + +if(prodid != "") +{ + var p2pUtils = new Prod2ProdUtils(prodid); + result.object(p2pUtils.getPartsListForRecordContainer()); +} \ No newline at end of file diff --git a/entity/Prod2prod_entity/recordcontainers/jdito/onDelete.js b/entity/Prod2prod_entity/recordcontainers/jdito/onDelete.js new file mode 100644 index 0000000000..db58c1cefa --- /dev/null +++ b/entity/Prod2prod_entity/recordcontainers/jdito/onDelete.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.db"); + +db.deleteData("PROD2PROD", "PROD2PRODID = '" + vars.get("$field.UID") + "'"); \ No newline at end of file diff --git a/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js b/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js new file mode 100644 index 0000000000..a20684ae00 --- /dev/null +++ b/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js @@ -0,0 +1,25 @@ +import("system.datetime"); +import("system.vars"); +import("system.db"); + +var cols = [ "PROD2PRODID" + , "DEST_ID" + , "SOURCE_ID" + , "QUANTITY" + , "OPTIONAL" + , "TAKEPRICE" + , "DATE_NEW" + , "USER_NEW" ]; + +var vals = [ vars.get("$field.UID") + , vars.get("$field.DEST_ID") + , vars.get("$field.SOURCE_ID") + , vars.get("$field.QUANTITY") + , vars.get("$field.OPTIONAL") + , vars.get("$field.TAKEPRICE") + , vars.get("$field.DATE_NEW") + , vars.get("$field.USER_NEW") ]; + +var colTypes = db.getColumnTypes("PROD2PROD", cols); + +db.insertData("PROD2PROD", cols, colTypes, vals); \ No newline at end of file diff --git a/entity/Prod2prod_entity/recordcontainers/jdito/onUpdate.js b/entity/Prod2prod_entity/recordcontainers/jdito/onUpdate.js new file mode 100644 index 0000000000..93a576e2c7 --- /dev/null +++ b/entity/Prod2prod_entity/recordcontainers/jdito/onUpdate.js @@ -0,0 +1,23 @@ +import("system.datetime"); +import("system.vars"); +import("system.db"); + +var cols = [ "DEST_ID" + , "SOURCE_ID" + , "QUANTITY" + , "OPTIONAL" + , "TAKEPRICE" + , "DATE_EDIT" + , "USER_EDIT" ]; + +var vals = [ vars.get("$field.DEST_ID") + , vars.get("$field.SOURCE_ID") + , vars.get("$field.QUANTITY") + , vars.get("$field.OPTIONAL") + , vars.get("$field.TAKEPRICE") + , vars.get("$field.DATE_EDIT") + , vars.get("$field.USER_EDIT") ]; + +var colTypes = db.getColumnTypes("PROD2PROD", cols); + +db.updateData("PROD2PROD", cols, colTypes, vals, "PROD2PRODID = '" + vars.get("$field.UID") + "'"); \ No newline at end of file -- GitLab