From e955b1989e1794f988fe062a3ff3c644156d9390 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Tue, 12 Feb 2019 12:53:00 +0100 Subject: [PATCH] Object relation fixes --- .../ObjectRelation_entity.aod | 22 ++++++++++-- .../anytargetrowid/valueProcess.js | 25 +++++++++++++ .../anytargettype/valueProcess.js | 26 ++++++++++++++ .../object1_rowid/valueProcess.js | 7 ++++ .../object2_rowid/valueProcess.js | 4 +++ .../children/objecttype_param/code.js | 2 -- .../ObjectRelation_context.aod | 5 +++ .../ObjectRelationEdit_view.aod | 35 +++++++++++++++++++ 8 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 entity/ObjectRelation_entity/entityfields/anytargetrowid/valueProcess.js create mode 100644 entity/ObjectRelation_entity/entityfields/anytargettype/valueProcess.js create mode 100644 neonView/ObjectRelationEdit_view/ObjectRelationEdit_view.aod diff --git a/entity/ObjectRelation_entity/ObjectRelation_entity.aod b/entity/ObjectRelation_entity/ObjectRelation_entity.aod index 98287676045..f182efcba85 100644 --- a/entity/ObjectRelation_entity/ObjectRelation_entity.aod +++ b/entity/ObjectRelation_entity/ObjectRelation_entity.aod @@ -14,6 +14,7 @@ <title>Type 1</title> <consumer>Contexts</consumer> <linkedContext>Context_context</linkedContext> + <mandatory v="true" /> <stateProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_type/stateProcess.js</stateProcess> <valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_type/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_type/displayValueProcess.js</displayValueProcess> @@ -23,6 +24,7 @@ <title>Object 1</title> <consumer>Objects1</consumer> <linkedContextProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_rowid/linkedContextProcess.js</linkedContextProcess> + <mandatory v="true" /> <stateProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_rowid/stateProcess.js</stateProcess> <valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_rowid/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_rowid/displayValueProcess.js</displayValueProcess> @@ -35,6 +37,7 @@ <title>Object 2</title> <consumer>Objects2</consumer> <linkedContextProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_rowid/linkedContextProcess.js</linkedContextProcess> + <mandatory v="true" /> <stateProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_rowid/stateProcess.js</stateProcess> <valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_rowid/valueProcess.js</valueProcess> </entityField> @@ -43,6 +46,7 @@ <title>Type 2</title> <consumer>Contexts</consumer> <linkedContext>Context_context</linkedContext> + <mandatory v="true" /> <stateProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_type/stateProcess.js</stateProcess> <valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_type/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_type/displayValueProcess.js</displayValueProcess> @@ -56,6 +60,8 @@ <entityProvider> <name>Object1</name> <fieldType>DEPENDENCY_IN</fieldType> + <targetContextField>OBJECT2_TYPE</targetContextField> + <targetIdField>OBJECT2_ROWID</targetIdField> <recordContainer>db</recordContainer> <dependencies> <entityDependency> @@ -105,6 +111,8 @@ <entityProvider> <name>Object2</name> <fieldType>DEPENDENCY_IN</fieldType> + <targetContextField>OBJECT1_TYPE</targetContextField> + <targetIdField>OBJECT1_ROWID</targetIdField> <recordContainer>db</recordContainer> <children> <entityParameter> @@ -136,6 +144,8 @@ <entityProvider> <name>BothObjects</name> <fieldType>DEPENDENCY_IN</fieldType> + <targetContextField>OBJECT2_TYPE</targetContextField> + <targetIdField>OBJECT2_ROWID</targetIdField> <recordContainer>db</recordContainer> <children> <entityParameter> @@ -191,8 +201,8 @@ <entityProvider> <name>AnyObject</name> <fieldType>DEPENDENCY_IN</fieldType> - <targetContextField>OBJECT1_TYPE</targetContextField> - <targetIdField>OBJECT1_ROWID</targetIdField> + <targetContextField>AnyTargetType</targetContextField> + <targetIdField>AnyTargetRowid</targetIdField> <recordContainer>db</recordContainer> <dependencies> <entityDependency> @@ -286,6 +296,14 @@ </entityParameter> </children> </entityConsumer> + <entityField> + <name>AnyTargetRowid</name> + <valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/anytargetrowid/valueProcess.js</valueProcess> + </entityField> + <entityField> + <name>AnyTargetType</name> + <valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/anytargettype/valueProcess.js</valueProcess> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/ObjectRelation_entity/entityfields/anytargetrowid/valueProcess.js b/entity/ObjectRelation_entity/entityfields/anytargetrowid/valueProcess.js new file mode 100644 index 00000000000..9f0983d754b --- /dev/null +++ b/entity/ObjectRelation_entity/entityfields/anytargetrowid/valueProcess.js @@ -0,0 +1,25 @@ +import("system.result"); +import("system.vars"); + +var openedType; +var openedRowid; + +// any object +if (vars.exists("$param.AnyObjectType_param") && vars.get("$param.AnyObjectType_param")) +{ + openedType = vars.get("$param.AnyObjectType_param"); + if (vars.exists("$param.Object1Rowid_param") && vars.get("$param.Object1Rowid_param")) + { + openedRowid = vars.get("$param.Object1Rowid_param"); + // anyObject and object 1 == opened object --> target is object2 + if (vars.get("$field.OBJECT1_ROWID") == openedRowid && vars.get("$field.OBJECT1_TYPE") == openedType) + { + result.string(vars.get(vars.get("$field.OBJECT2_ROWID"))); + } + // anyObject and object 2 == opened object --> target is object1 + else if (vars.get("$field.OBJECT2_ROWID") == openedRowid && vars.get("$field.OBJECT2_TYPE") == openedType) + { + result.string(vars.get(vars.get("$field.OBJECT1_ROWID"))); + } + } +} \ No newline at end of file diff --git a/entity/ObjectRelation_entity/entityfields/anytargettype/valueProcess.js b/entity/ObjectRelation_entity/entityfields/anytargettype/valueProcess.js new file mode 100644 index 00000000000..4edbbede26f --- /dev/null +++ b/entity/ObjectRelation_entity/entityfields/anytargettype/valueProcess.js @@ -0,0 +1,26 @@ +import("system.logging"); +import("system.result"); +import("system.vars"); + +var openedType; +var openedRowid; + +// any object +if (vars.exists("$param.AnyObjectType_param") && vars.get("$param.AnyObjectType_param")) +{ + openedType = vars.get("$param.AnyObjectType_param"); + if (vars.exists("$param.Object1Rowid_param") && vars.get("$param.Object1Rowid_param")) + { + openedRowid = vars.get("$param.Object1Rowid_param"); + // anyObject and object 1 == opened object --> target is object2 + if (vars.get("$field.OBJECT1_ROWID") == openedRowid && vars.get("$field.OBJECT1_TYPE") == openedType) + { + result.string(vars.get(vars.get("$field.OBJECT2_TYPE"))); + } + // anyObject and object 2 == opened object --> target is object1 + else if (vars.get("$field.OBJECT2_ROWID") == openedRowid && vars.get("$field.OBJECT2_TYPE") == openedType) + { + result.string(vars.get(vars.get("$field.OBJECT1_TYPE"))); + } + } +} \ No newline at end of file diff --git a/entity/ObjectRelation_entity/entityfields/object1_rowid/valueProcess.js b/entity/ObjectRelation_entity/entityfields/object1_rowid/valueProcess.js index d189f026bbd..ddfeaf3a855 100644 --- a/entity/ObjectRelation_entity/entityfields/object1_rowid/valueProcess.js +++ b/entity/ObjectRelation_entity/entityfields/object1_rowid/valueProcess.js @@ -1,8 +1,11 @@ +import("system.logging"); import("system.result"); import("system.neon"); import("system.vars"); var recordstate = vars.get("$sys.recordstate"); +logging.log(recordstate) + if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT) { if (vars.exists("$param.AnyObjectRowid_param") && vars.get("$param.AnyObjectRowid_param")) @@ -13,4 +16,8 @@ if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE { result.string(vars.get("$param.Object1Rowid_param")); } + else if (!vars.get("$field.OBJECT2_TYPE")) + { + result.string(""); + } } \ No newline at end of file diff --git a/entity/ObjectRelation_entity/entityfields/object2_rowid/valueProcess.js b/entity/ObjectRelation_entity/entityfields/object2_rowid/valueProcess.js index 710c40de475..907eff1114e 100644 --- a/entity/ObjectRelation_entity/entityfields/object2_rowid/valueProcess.js +++ b/entity/ObjectRelation_entity/entityfields/object2_rowid/valueProcess.js @@ -9,4 +9,8 @@ if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE { result.string(vars.get("$param.Object2Rowid_param")); } + else if (!vars.get("$field.OBJECT2_TYPE")) + { + result.string(""); + } } \ No newline at end of file diff --git a/entity/ObjectRelation_entity/entityfields/objects1/children/objecttype_param/code.js b/entity/ObjectRelation_entity/entityfields/objects1/children/objecttype_param/code.js index 3b6f82bbcec..0e35811c9fc 100644 --- a/entity/ObjectRelation_entity/entityfields/objects1/children/objecttype_param/code.js +++ b/entity/ObjectRelation_entity/entityfields/objects1/children/objecttype_param/code.js @@ -1,6 +1,4 @@ -import("system.logging"); import("system.vars"); import("system.result"); -logging.log("set type: " + vars.get("$field.OBJECT1_TYPE")) result.string(vars.get("$field.OBJECT1_TYPE")) \ No newline at end of file diff --git a/neonContext/ObjectRelation_context/ObjectRelation_context.aod b/neonContext/ObjectRelation_context/ObjectRelation_context.aod index 4e07153b0da..e8d0ed985d8 100644 --- a/neonContext/ObjectRelation_context/ObjectRelation_context.aod +++ b/neonContext/ObjectRelation_context/ObjectRelation_context.aod @@ -3,6 +3,7 @@ <name>ObjectRelation_context</name> <majorModelMode>DISTRIBUTED</majorModelMode> <filterview>ObjectRelationFilter_view</filterview> + <editview>ObjectRelationEdit_view</editview> <preview>ObjectRelationPreview_view</preview> <entity>ObjectRelation_entity</entity> <references> @@ -14,5 +15,9 @@ <name>dc0bd793-a472-4a7b-8394-06c4bc31258a</name> <view>ObjectRelationPreview_view</view> </neonViewReference> + <neonViewReference> + <name>30334c84-5e46-4a4e-a5c4-3c42d1cb109b</name> + <view>ObjectRelationEdit_view</view> + </neonViewReference> </references> </neonContext> diff --git a/neonView/ObjectRelationEdit_view/ObjectRelationEdit_view.aod b/neonView/ObjectRelationEdit_view/ObjectRelationEdit_view.aod new file mode 100644 index 00000000000..6f701953cc8 --- /dev/null +++ b/neonView/ObjectRelationEdit_view/ObjectRelationEdit_view.aod @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.1"> + <name>ObjectRelationEdit_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <boxLayout> + <name>layout</name> + </boxLayout> + </layout> + <children> + <genericViewTemplate> + <name>Objects</name> + <editMode v="true" /> + <entityField>#ENTITY</entityField> + <fields> + <entityFieldLink> + <name>4bb47cac-47a7-448f-a8e6-ebab641d984f</name> + <entityField>OBJECT1_TYPE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>3c548c29-1f77-47e1-bbad-b3063b71224d</name> + <entityField>OBJECT1_ROWID</entityField> + </entityFieldLink> + <entityFieldLink> + <name>7cfab0c5-06c7-4b1d-84e8-97aa76d5e4f3</name> + <entityField>OBJECT2_TYPE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>d0b4d4b6-ab29-478f-9e07-9de07fed0c32</name> + <entityField>OBJECT2_ROWID</entityField> + </entityFieldLink> + </fields> + </genericViewTemplate> + </children> +</neonView> -- GitLab