diff --git a/entity/Address_entity/Address_entity.aod b/entity/Address_entity/Address_entity.aod index 5741c166cb1abcbf82333071d6b02dff006d62cc..5d8740b619a404206c6bf51ac84b39b1cb07a5aa 100644 --- a/entity/Address_entity/Address_entity.aod +++ b/entity/Address_entity/Address_entity.aod @@ -79,6 +79,12 @@ <fieldName>Addresses</fieldName> <isConsumer v="false" /> </entityDependency> + <entityDependency> + <name>f6e4be75-2810-4c39-86c7-710f1b72b172</name> + <entityName>Contact_entity</entityName> + <fieldName>Addresses</fieldName> + <isConsumer v="false" /> + </entityDependency> </dependencies> <children> <entityParameter> diff --git a/entity/Contact_entity/Contact_entity.aod b/entity/Contact_entity/Contact_entity.aod new file mode 100644 index 0000000000000000000000000000000000000000..c758ccea00f22fa88427282584aebe24ec9795d2 --- /dev/null +++ b/entity/Contact_entity/Contact_entity.aod @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8"?> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.0"> + <name>Contact_entity</name> + <title>Contact</title> + <majorModelMode>DISTRIBUTED</majorModelMode> + <documentation>%aditoprj%/entity/Contact_entity/documentation.adoc</documentation> + <icon>VAADIN:USERS</icon> + <recordContainer>db</recordContainer> + <entityFields> + <entityProvider> + <name>#PROVIDER</name> + </entityProvider> + <entityField> + <name>CONTACTID</name> + </entityField> + <entityField> + <name>ORGANISATION_ID</name> + <title>Organisation</title> + <consumer>Organisations</consumer> + <mandatory v="true" /> + </entityField> + <entityField> + <name>PERSON_ID</name> + <title>Contact</title> + <mandatory v="true" /> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/Contact_entity/entityfields/person_id/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/Contact_entity/entityfields/person_id/displayValueProcess.js</displayValueProcess> + </entityField> + <entityField> + <name>DEPARTMENT</name> + <title>Deparment</title> + </entityField> + <entityField> + <name>POSITION</name> + <title>Position</title> + </entityField> + <entityField> + <name>CONTACTROLE</name> + <title>Contactrole</title> + </entityField> + <entityConsumer> + <name>Organisations</name> + <fieldType>DEPENDENCY_OUT</fieldType> + <dependency> + <name>dependency</name> + <entityName>Organisation_entity</entityName> + <fieldName>#PROVIDER</fieldName> + </dependency> + </entityConsumer> + <entityParameter> + <name>PersonId_param</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> + <entityProvider> + <name>PersonRelated</name> + <fieldType>DEPENDENCY_IN</fieldType> + </entityProvider> + <entityField> + <name>ADDRESS_ID</name> + <title>standard address</title> + <consumer>Addresses</consumer> + </entityField> + <entityConsumer> + <name>Addresses</name> + <fieldType>DEPENDENCY_OUT</fieldType> + <dependency> + <name>dependency</name> + <entityName>Address_entity</entityName> + <fieldName>OrganisationAddresses</fieldName> + </dependency> + <children> + <entityParameter> + <name>ContactId_param</name> + <valueProcess>%aditoprj%/entity/Contact_entity/entityfields/addresses/children/contactid_param/valueProcess.js</valueProcess> + <triggerRecalculation v="true" /> + </entityParameter> + </children> + </entityConsumer> + </entityFields> + <recordContainers> + <dbRecordContainer> + <name>db</name> + <alias>Data_alias</alias> + <linkInformation> + <linkInformation> + <name>d2a29013-e270-4ce1-8f2d-b372206f0aa3</name> + <tableName>CONTACT</tableName> + <primaryKey>CONTACTID</primaryKey> + <isUIDTable v="true" /> + <readonly v="false" /> + </linkInformation> + </linkInformation> + <recordFieldMappings> + <dbRecordFieldMapping> + <name>CONTACTID.value</name> + <recordfield>CONTACT.CONTACTID</recordfield> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>ORGANISATION_ID.value</name> + <recordfield>CONTACT.ORGANISATION_ID</recordfield> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>PERSON_ID.value</name> + <recordfield>CONTACT.PERSON_ID</recordfield> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>DEPARTMENT.value</name> + <recordfield>CONTACT.DEPARTMENT</recordfield> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>POSITION.value</name> + <recordfield>CONTACT.POSTITION</recordfield> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>CONTACTROLE.value</name> + <recordfield>CONTACT.CONTACTROLE</recordfield> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>ADDRESS_ID.value</name> + <recordfield>CONTACT.ADDRESS_ID</recordfield> + </dbRecordFieldMapping> + </recordFieldMappings> + </dbRecordContainer> + </recordContainers> +</entity> diff --git a/entity/Contact_entity/documentation.adoc b/entity/Contact_entity/documentation.adoc new file mode 100644 index 0000000000000000000000000000000000000000..46715c6b8ede44d2f5fd9939abccce23b71dcf63 --- /dev/null +++ b/entity/Contact_entity/documentation.adoc @@ -0,0 +1 @@ +Represents a Contact without detail information to Organisations/Persons \ No newline at end of file diff --git a/entity/Contact_entity/entityfields/addresses/children/contactid_param/valueProcess.js b/entity/Contact_entity/entityfields/addresses/children/contactid_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..d311affe18306b0906292c54e6552e0836cacea6 --- /dev/null +++ b/entity/Contact_entity/entityfields/addresses/children/contactid_param/valueProcess.js @@ -0,0 +1,15 @@ +import("system.logging"); +import("system.result"); +import("system.db"); +import("system.vars"); +import("Sql_lib"); + +var orgId = vars.get("$field.ORGANISATION_ID"); +if (orgId) +{ + var orgContactId = db.cell(SqlCondition.begin() + .andPrepare("CONTACT.ORGANISATION_ID", orgId) + .and("CONTACT.PERSON_ID is null") + .buildSql("select CONTACT.CONTACTID from CONTACT")); + result.string(orgContactId); +} \ No newline at end of file diff --git a/entity/Contact_entity/entityfields/person_id/displayValueProcess.js b/entity/Contact_entity/entityfields/person_id/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..ac84e0c619889be04f65f76e75a3d79688b94e28 --- /dev/null +++ b/entity/Contact_entity/entityfields/person_id/displayValueProcess.js @@ -0,0 +1,10 @@ +import("system.result"); +import("system.vars"); +import("Contact_lib"); + +var persId = vars.get("$field.PERSON_ID"); +var res = ""; +if (persId) + res = ContactUtils.getTitleByPersonId(persId); + +result.string(res); \ No newline at end of file diff --git a/entity/Contact_entity/entityfields/person_id/valueProcess.js b/entity/Contact_entity/entityfields/person_id/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..7803b90af373762f4ae921f51bdadf4386ac9469 --- /dev/null +++ b/entity/Contact_entity/entityfields/person_id/valueProcess.js @@ -0,0 +1,7 @@ +import("system.vars"); +import("system.result"); +import("system.neon"); + +var presetValue = vars.get("$param.PersonId_param"); +if (presetValue && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$this.value")) + result.string(presetValue); \ No newline at end of file diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index 602273e1111251caeb5b6b9bc8780210a72824f1..192752bfcdec3931dbff323682b3e1701616e658 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -259,6 +259,12 @@ <fieldName>Organisations</fieldName> <isConsumer v="false" /> </entityDependency> + <entityDependency> + <name>08439676-9146-427b-9bc6-8d6c6c7548d7</name> + <entityName>Contact_entity</entityName> + <fieldName>Organisations</fieldName> + <isConsumer v="false" /> + </entityDependency> </dependencies> </entityProvider> <entityConsumer> diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod index fecc091a4bd3f90cc19b1c9a5a94693c900cc6e5..ba7b6d24f4b557bb3946928fdcdcfaabc6cbbe04 100644 --- a/entity/Person_entity/Person_entity.aod +++ b/entity/Person_entity/Person_entity.aod @@ -694,6 +694,13 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact </entityParameter> </children> </entityConsumer> + <entityActionField> + <name>newContact</name> + <fieldType>ACTION</fieldType> + <title>new contact</title> + <onActionProcess>%aditoprj%/entity/Person_entity/entityfields/newcontact/onActionProcess.js</onActionProcess> + <iconId>VAADIN:USERS</iconId> + </entityActionField> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Person_entity/entityfields/newcontact/onActionProcess.js b/entity/Person_entity/entityfields/newcontact/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..98a6f340f6161c31afe248044b504abb8fd2b78f --- /dev/null +++ b/entity/Person_entity/entityfields/newcontact/onActionProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.neon"); + +neon.openContext("Contact", null, null, neon.OPERATINGSTATE_NEW, {PersonId_param: vars.get("$field.PERSON_ID")}); \ No newline at end of file diff --git a/neonContext/Contact/Contact.aod b/neonContext/Contact/Contact.aod new file mode 100644 index 0000000000000000000000000000000000000000..9a0e9a6ac170597a402dab51cdbca7b7217e17d0 --- /dev/null +++ b/neonContext/Contact/Contact.aod @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0"> + <name>Contact</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <editview>ContactEdit_view</editview> + <entity>Contact_entity</entity> + <references> + <neonViewReference> + <name>c96479fe-4f9c-433d-9de3-c2e1bbb5aac7</name> + <view>ContactEdit_view</view> + </neonViewReference> + </references> +</neonContext> diff --git a/neonView/ContactEdit_view/ContactEdit_view.aod b/neonView/ContactEdit_view/ContactEdit_view.aod new file mode 100644 index 0000000000000000000000000000000000000000..472f3dcc83f9a2e0fe1c5eb06f7e21a508706d7d --- /dev/null +++ b/neonView/ContactEdit_view/ContactEdit_view.aod @@ -0,0 +1,43 @@ +<?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.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.0"> + <name>ContactEdit_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <boxLayout> + <name>layout</name> + </boxLayout> + </layout> + <children> + <genericViewTemplate> + <name>data</name> + <editMode v="true" /> + <entityField>#ENTITY</entityField> + <fields> + <entityFieldLink> + <name>b43e201f-b6be-43d7-af03-5cc7defe1a1e</name> + <entityField>PERSON_ID</entityField> + </entityFieldLink> + <entityFieldLink> + <name>40d2367e-c197-424c-8442-9b04c7369e3a</name> + <entityField>ORGANISATION_ID</entityField> + </entityFieldLink> + <entityFieldLink> + <name>e6db316a-cc0b-47b7-9773-1ae72a57ff14</name> + <entityField>ADDRESS_ID</entityField> + </entityFieldLink> + <entityFieldLink> + <name>74e712fb-595f-4f96-9ecb-bd6a99948dce</name> + <entityField>CONTACTROLE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>847e9231-d6df-4ead-903d-b70dbcd69333</name> + <entityField>DEPARTMENT</entityField> + </entityFieldLink> + <entityFieldLink> + <name>e7c57e62-ff21-4ccd-8458-55d2fcca7b97</name> + <entityField>POSITION</entityField> + </entityFieldLink> + </fields> + </genericViewTemplate> + </children> +</neonView> diff --git a/process/Contact_lib/process.js b/process/Contact_lib/process.js index dfe2c88b7b0f91219ea2f4fa54d047364d21bb25..628de9c354be6ef009c430f68d0d91d77f2dbca9 100644 --- a/process/Contact_lib/process.js +++ b/process/Contact_lib/process.js @@ -213,6 +213,32 @@ ContactUtils.getFullTitleByContactId = function(pContactId) return ""; } +/** + * get the name of the person + * + * @param {String} pPersonId the id of the person where the data shall be loaded + * + * @return {String} the name or "" + */ +ContactUtils.getTitleByPersonId = function(pPersonId) +{ + if (pPersonId) + { + var data = db.array(db.ROW, SqlCondition.begin() + .andPrepare("PERSON.PERSONID", pPersonId) + .buildSql("select PERSON.SALUTATION, PERSON.TITLE, PERSON.FIRSTNAME, PERSON.MIDDLENAME, PERSON.LASTNAME " + + "from PERSON", "1 = 2")); + if (data.length == 0) + return ""; + var contact = new Contact(); + [contact.salutation, contact.title, contact.firstname, contact.middlename, contact.lastname] = data; + var renderer = new ContactTitleRenderer(contact); + return renderer.asString(); + } + + return ""; +} + /** * returns the from string for the contact joined with org, person, address *