diff --git a/entity/Address_entity/Address_entity.aod b/entity/Address_entity/Address_entity.aod index 014b132b6cb27d75a2e3c00c23fb1d3f5087c7f5..f3b70c507fa6e79e51b7680348e5016927de1b27 100644 --- a/entity/Address_entity/Address_entity.aod +++ b/entity/Address_entity/Address_entity.aod @@ -61,6 +61,7 @@ </entityField> <entityField> <name>RELATION_ID</name> + <mandatory v="true" /> <valueProcess>%aditoprj%/entity/Address_entity/entityfields/relation_id/valueProcess.js</valueProcess> </entityField> <entityField> @@ -152,6 +153,11 @@ <documentation>%aditoprj%/entity/Address_entity/entityfields/defaultaddressid_param/documentation.adoc</documentation> <description>provide a ADDRESSID-value of the standard address (of a RELATION)</description> </entityParameter> + <entityField> + <name>RelationType</name> + <contentType>NUMBER</contentType> + <valueProcess>%aditoprj%/entity/Address_entity/entityfields/relationtype/valueProcess.js</valueProcess> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Address_entity/entityfields/addr_type/documentation.adoc b/entity/Address_entity/entityfields/addr_type/documentation.adoc index 89006f557fe82a7c4e09ffc1ab9f9050f8ac0f3a..09d2a04725d29e9db5d208b45fc7d6dc197f0225 100644 --- a/entity/Address_entity/entityfields/addr_type/documentation.adoc +++ b/entity/Address_entity/entityfields/addr_type/documentation.adoc @@ -1,4 +1,9 @@ +ADDR_TYPE +========= + The `ADDR_TYPE` field represents the type of address (like "shipping address", "private address", etc.) +Possible values depend on the type of object it's connect to since a contactperson has different types than a company (organisation). -Possible values depend on the type of object it's connect to since a contactperson has different types than a company (organisation). \ No newline at end of file +The Keyword ADDRESS.TYPE contains the following custom properties: {org: true, pers: false} +The types are filtered by the current relation type in the possibleItemsProcess. \ No newline at end of file diff --git a/entity/Address_entity/entityfields/addr_type/possibleItemsProcess.js b/entity/Address_entity/entityfields/addr_type/possibleItemsProcess.js index 5403dab1fe30bb4e2a996f3d9659977fc4f8082d..9b37906c7bd5f390db426ce1dd22861676e9474f 100644 --- a/entity/Address_entity/entityfields/addr_type/possibleItemsProcess.js +++ b/entity/Address_entity/entityfields/addr_type/possibleItemsProcess.js @@ -1,7 +1,27 @@ +import("system.vars"); import("system.result"); import("Keyword_lib"); +import("Relation_lib"); -var items; +var type = parseInt(vars.get("$field.RelationType")); +var fields = []; -items = KeywordUtils.getStandardArray("ADDRESS.TYPE"); -result.object(items); \ No newline at end of file +switch (type) { + case 1: + fields = ["org"]; + break; + case 2: + case 3: + fields = ["pers"]; + break; +} + +result.object(KeywordUtils.getStandardArrayProps("ADDRESS.TYPE").filter(function (pKeyword) { + for (let i = 0; i < fields.length; i++) { + if (pKeyword[2][fields[i]]) { + return true; + } + } + + return false; +})); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/relation_id/valueProcess.js b/entity/Address_entity/entityfields/relation_id/valueProcess.js index 2d085e3aff5efa91eca352d8fc20a4c2c7bbdd4a..61a5ce97dd4ee046ca818ee01aaca846e966e3be 100644 --- a/entity/Address_entity/entityfields/relation_id/valueProcess.js +++ b/entity/Address_entity/entityfields/relation_id/valueProcess.js @@ -4,6 +4,6 @@ import("system.vars"); if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW) { - if(vars.exists("$param.RelId_param") && vars.get("$param.RelId_param") != null) + if(vars.exists("$param.RelId_param") && vars.getString("$param.RelId_param")) result.string(vars.getString("$param.RelId_param")); } \ No newline at end of file diff --git a/entity/Address_entity/entityfields/relationtype/valueProcess.js b/entity/Address_entity/entityfields/relationtype/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..73d8117e07d90265b94c00f1cae42648f1a2dc77 --- /dev/null +++ b/entity/Address_entity/entityfields/relationtype/valueProcess.js @@ -0,0 +1,5 @@ +import("system.result"); +import("system.vars"); +import("Relation_lib") + +result.object(RelationUtils.getRelationTypeByRelation(vars.get("$field.RELATION_ID"))); \ No newline at end of file diff --git a/others/db_changes/data/example_org/ORG_gfk.xml b/others/db_changes/data/example_org/ORG_gfk.xml index b1d396a2c7f60845ca1f3d443d23cd8c4ef239b1..1b4ab630fbdcd1abbf7c90758b91462a3fdb427d 100644 --- a/others/db_changes/data/example_org/ORG_gfk.xml +++ b/others/db_changes/data/example_org/ORG_gfk.xml @@ -50,7 +50,7 @@ </insert> <insert tableName="ADDRESS"> <column name="STATE" value="Bayern"/> - <column name="ADDR_TYPE" valueNumeric="2"/> + <column name="ADDR_TYPE" valueNumeric="1"/> <column name="DATE_NEW" valueDate="2018-07-02T00:00:00"/> <column name="CITY" value="MÞnchen"/> <column name="COUNTRY" value="DE"/> diff --git a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod index a2f250851f5539a01030db9136a5121fe824286f..5edf76c7779d54bddc411de7cb54029b31b8bf2f 100644 --- a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod +++ b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod @@ -2,7 +2,7 @@ <preferences xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="3.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/preferences/3.0.3"> <name>_____PREFERENCES_PROJECT</name> <majorModelMode>DISTRIBUTED</majorModelMode> - <projectName>xRM-Basic-5-1</projectName> + <projectName>xRM-Basic5</projectName> <jditoMaxContentSize v="57671680" /> <calendarCategoriesEvent> <entry> diff --git a/process/Keyword_lib/process.js b/process/Keyword_lib/process.js index 2eeba8572303f23e132ee1a1f650d2fe57d624cd..377b2137a828e5a2f7df55df67f767e93e491c28 100644 --- a/process/Keyword_lib/process.js +++ b/process/Keyword_lib/process.js @@ -23,6 +23,20 @@ function KeywordUtils(){ KeywordUtils.getStandardArray = function(keywordType){ return KeywordUtils.createKeyword(keywordType).toArray(["id", "name"]); } + + /** + * same as getStandardArray but also returns the custom properties + * @param {String} keywordType specifies the type of the keyword and therefore the list elements; e.g. "COUNTRY" + * @return {Array} a 2D array in form of [["id1", "name1", {"prop1":"prop"}], ["idN", "nameN", {"prop1":"prop"}]] + * @example + * var items; + * + * items = KeywordUtils.getStandardArray("ADDRESS.TYPE"); + * result.object(items); + */ + KeywordUtils.getStandardArrayProps = function(keywordType){ + return KeywordUtils.createKeyword(keywordType).toArray(["id", "name", "customProperties"]); + } /** * get a Keyword by type and key @@ -119,10 +133,10 @@ function KeywordUtils(){ break; case "ADDRESS.TYPE": valueContainer = _createKeywordEntriesContainer([ - _createKeywordEntry("1", translate.text("Office address")) - ,_createKeywordEntry("2", translate.text("Home address")) - ,_createKeywordEntry("3", translate.text("Delivery address")) - ,_createKeywordEntry("4", translate.text("Post office box")) + _createKeywordEntry("1", translate.text("Office address"), null, {org: true, pers: false}) + ,_createKeywordEntry("2", translate.text("Home address"), null, {org: false, pers: true}) + ,_createKeywordEntry("3", translate.text("Delivery address"), null, {org: true, pers: true}) + ,_createKeywordEntry("4", translate.text("Post office box"), null, {org: true, pers: true}) ]); break; case "ORG.TYPE": @@ -405,14 +419,13 @@ function KeywordUtils(){ }; _getPropsForKeyFn = function(key, fields) { - var keyObject, i, l, currentRow, currentField; + var keyObject, i, currentRow, currentField; keyObject = valueContainer[key]; if (keyObject == undefined) return [];//TODO: throw error instead? - l = fields.length; currentRow = []; - for (i = 0; i < l; i++){ + for (i = 0; i < fields.length; i++){ currentField = fields[i]; //check if the passed fieldnames match the existing fieldnames (<=> properties in the object) //to prevent errors and unexpected behaviour diff --git a/process/Relation_lib/process.js b/process/Relation_lib/process.js index b28903b7dbe11d3f043ca17568be9e20707f37b4..fdcced185adc8437f7303883a79ee8fdadb13d4d 100644 --- a/process/Relation_lib/process.js +++ b/process/Relation_lib/process.js @@ -16,7 +16,7 @@ function RelationUtils() {} * If you already have persId and orgId from the RELATION table, use getRelationTypeByPersOrg() <br> * @param {String} pRelationId * <br> - * @return {String} 0 if relationId not found <br> + * @return {Integer} 0 if relationId not found <br> * 1 if organisation <br> * 2 if privat person <br> * 3 if person of an organisation <br> @@ -55,7 +55,7 @@ RelationUtils.getRelationTypeByRelation = function(pRelationId) * @param {String} pPersId selected from the RELATION table * @param {String} pOrgId selected from the RELATION table * <br> - * @return {String} <br>1 if organisation <br> + * @return {Integer} <br>1 if organisation <br> * 2 if privat person <br> * 3 if person of an organisation <br> */