Skip to content
Snippets Groups Projects
Commit c4282e52 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

Merge #1030762-different-address-types

Conflicts:
	entity/Address_entity/entityfields/addr_type/documentation.adoc
parents ed5779df 3974a3cb
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
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
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
......@@ -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
import("system.result");
import("system.vars");
import("Relation_lib")
result.object(RelationUtils.getRelationTypeByRelation(vars.get("$field.RELATION_ID")));
\ No newline at end of file
......@@ -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"/>
......
......@@ -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>
......
......@@ -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
......
......@@ -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>
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment