Skip to content
Snippets Groups Projects
Commit b70a4e47 authored by S.Listl's avatar S.Listl
Browse files

Write email action in Person

parent 086690d5
No related branches found
No related tags found
No related merge requests found
Showing
with 318 additions and 9 deletions
......@@ -135,6 +135,7 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
<entityProvider>
<name>EmailCommunications</name>
<fieldType>DEPENDENCY_IN</fieldType>
<lookupIdfield>ADDR</lookupIdfield>
<recordContainer>db</recordContainer>
<dependencies>
<entityDependency>
......@@ -149,6 +150,12 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
<fieldName>EmailCommunications</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>b5ebddec-002b-40a5-a760-cedb78e94cfb</name>
<entityName>Email_entity</entityName>
<fieldName>EmailAddresses</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
<children>
<entityParameter>
......
......@@ -10,6 +10,14 @@
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
<dependencies>
<entityDependency>
<name>5cc2e566-309c-4b47-84f3-52376e919b9b</name>
<entityName>Email_entity</entityName>
<fieldName>DocumnetTemplates</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
</entityProvider>
<entityField>
<name>DATE_EDIT</name>
......
<?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.5" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.5">
<name>Email_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<recordContainer>jdito</recordContainer>
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
</entityProvider>
<entityField>
<name>UID</name>
</entityField>
<entityField>
<name>DOCUMENT_TEMPLATE</name>
<title>Document Template</title>
<consumer>DocumnetTemplates</consumer>
<linkedContext>DocumentTemplate</linkedContext>
</entityField>
<entityConsumer>
<name>DocumnetTemplates</name>
<fieldType>DEPENDENCY_OUT</fieldType>
<dependency>
<name>dependency</name>
<entityName>DocumentTemplate_entity</entityName>
<fieldName>#PROVIDER</fieldName>
</dependency>
</entityConsumer>
<entityParameter>
<name>Recipient_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityField>
<name>RECIPIENT</name>
<title>Recipient</title>
<consumer>EmailAddresses</consumer>
<valueProcess>%aditoprj%/entity/Email_entity/entityfields/recipient/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/Email_entity/entityfields/recipient/displayValueProcess.js</displayValueProcess>
</entityField>
<entityConsumer>
<name>EmailAddresses</name>
<fieldType>DEPENDENCY_OUT</fieldType>
<dependency>
<name>dependency</name>
<entityName>Communication_entity</entityName>
<fieldName>EmailCommunications</fieldName>
</dependency>
<children>
<entityParameter>
<name>ContactId_param</name>
<valueProcess>%aditoprj%/entity/Email_entity/entityfields/emailaddresses/children/contactid_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityParameter>
<name>ContactId_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
<name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<onInsert>%aditoprj%/entity/Email_entity/recordcontainers/jdito/onInsert.js</onInsert>
<recordFields>
<element>UID.value</element>
</recordFields>
</jDitoRecordContainer>
</recordContainers>
</entity>
import("system.vars");
import("system.result");
if (vars.exists("$param.ContactId_param") && vars.get("$param.ContactId_param"))
result.string(vars.get("$param.ContactId_param"));
\ No newline at end of file
import("system.result");
import("system.neon");
import("system.vars");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
result.string(vars.get("$this.value"));
\ No newline at end of file
import("Communication_lib");
import("system.result");
import("system.neon");
import("system.vars");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$this.value"))
{
if (vars.exists("$param.Recipient_param") && vars.get("$param.Recipient_param"))
result.string(vars.get("$param.Recipient_param"));
else if (vars.exists("$param.ContactId_param") && vars.get("$param.ContactId_param"))
result.string(CommUtil.getStandardMail(vars.get("$param.ContactId_param")));
}
\ No newline at end of file
import("Employee_lib");
import("system.vars");
import("Email_lib");
EmailUtils.openMailTemplate(vars.get("$field.RECIPIENT"), EmployeeUtils.getCurrentContactId(), vars.get("$field.DOCUMENT_TEMPLATE"));
\ No newline at end of file
......@@ -284,9 +284,6 @@
<fieldName>Documents</fieldName>
</dependency>
<children>
<entityParameter>
<name>AssignmentName_param</name>
</entityParameter>
<entityParameter>
<name>AssignmentRowId_param</name>
<valueProcess>%aditoprj%/entity/Offer_entity/entityfields/documents/children/assignmentrowid_param/valueProcess.js</valueProcess>
......@@ -307,9 +304,6 @@
<fieldName>MainDocuments</fieldName>
</dependency>
<children>
<entityParameter>
<name>AssignmentName_param</name>
</entityParameter>
<entityParameter>
<name>AssignmentRowId_param</name>
<valueProcess>%aditoprj%/entity/Offer_entity/entityfields/maindocuments/children/assignmentrowid_param/valueProcess.js</valueProcess>
......
......@@ -892,6 +892,13 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
</entityActionField>
</children>
</entityActionGroup>
<entityActionField>
<name>newEmail</name>
<fieldType>ACTION</fieldType>
<title>Write email</title>
<onActionProcess>%aditoprj%/entity/Person_entity/entityfields/newemail/onActionProcess.js</onActionProcess>
<iconId>VAADIN:AT</iconId>
</entityActionField>
</entityFields>
<recordContainers>
<dbRecordContainer>
......
import("system.vars");
import("Email_lib");
EmailUtils.openNewMail(vars.getString("$field.CONTACTID"));
\ No newline at end of file
......@@ -3825,6 +3825,9 @@
<entry>
<key>Attribute \"%0\" can't be used more than %1.</key>
</entry>
<entry>
<key>Recipient</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
<sqlModels>
......
......@@ -46,6 +46,10 @@
<key>Office staff</key>
<value>Innendienst</value>
</entry>
<entry>
<key>Recipient</key>
<value>Empfänger</value>
</entry>
<entry>
<key>Overdue tasks</key>
<value>Überfällige Aufgaben</value>
......@@ -74,6 +78,10 @@
<key>Salesproject phases</key>
<value>Vertriebsprojektphasen</value>
</entry>
<entry>
<key>Write email</key>
<value>E-Mail schreiben</value>
</entry>
<entry>
<key>${ATTRIBUTE_VOID}</key>
<value>Tag</value>
......
......@@ -3876,6 +3876,9 @@
<entry>
<key>Attribute \"%0\" can't be used more than %1.</key>
</entry>
<entry>
<key>Recipient</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
</language>
<?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>Email</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<entity>Email_entity</entity>
<references>
<neonViewReference>
<name>32d974db-e56a-49e7-b421-3abf02757580</name>
<view>EmailEdit_view</view>
</neonViewReference>
</references>
</neonContext>
<?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.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.1">
<name>EmailEdit_view</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<isSmall v="true" />
<layout>
<boxLayout>
<name>layout</name>
</boxLayout>
</layout>
<children>
<genericViewTemplate>
<name>Generic</name>
<editMode v="true" />
<entityField>#ENTITY</entityField>
<fields>
<entityFieldLink>
<name>bfcf8766-7e6d-4240-9cbd-54abfc5a1883</name>
<entityField>RECIPIENT</entityField>
</entityFieldLink>
<entityFieldLink>
<name>72441756-f00d-42a7-bd3f-a6f7964891bc</name>
<entityField>DOCUMENT_TEMPLATE</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
</children>
</neonView>
......@@ -117,9 +117,9 @@ CommUtil.getStandardSubSqlForCategory = function(pCategory, pContactField)
var cond = SqlCondition.begin();
if (pContactField == undefined)
cond.and("COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID");
else if (typeof(pRelationField) == "string")
else if (typeof(pContactField) == "string")
cond.andPrepare("COMMUNICATION.CONTACT_ID", pContactField);
else if (typeof(pRelationField) == "object")
else if (typeof(pContactField) == "object")
{
//you may want to sepcify a concrete value
cond.andSqlCondition(pContactField, "1=2");
......@@ -159,11 +159,26 @@ CommUtil.getStandardSubSqlPhone = function(pContactField)
* @param {String|SqlCondition} [pContactField=CONTACT.CONTACTID] SQL-fieldname that shall be used for filtering the CONTACT_ID, this can be a string(fieldname) or an SqlCondition object
* @return {String} sub-sql
*/
CommUtil.getStandardSubSqlMail= function(pContactField)
CommUtil.getStandardSubSqlMail = function(pContactField)
{
return CommUtil.getStandardSubSqlForCategory("EMAIL", pContactField);
};
/**
* returns a the standard address of a EMAIL-COMMUNICATION
*
* @param {String} pContactId the contactId
*
* @return {String} email address
*/
CommUtil.getStandardMail = function (pContactId)
{
var query = CommUtil.getStandardSubSqlMail(SqlCondition.begin()
.andPrepare("COMMUNICATION.CONTACT_ID", pContactId)
);
return db.cell(query);
}
/**
* provides static methods for validation of communication data
* do not create an instance of this
......
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1">
<name>Email_lib</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/Email_lib/process.js</process>
<variants>
<element>LIBRARY</element>
</variants>
</process>
import("system.text");
import("system.db");
import("system.util");
import("Communication_lib");
import("system.neon");
function EmailUtils () {}
EmailUtils.openMailTemplate = function (pToRecipients, pContactId, pTemplateId)
{
var email = new Email(pToRecipients);
email.setSender(pContactId);
if (pTemplateId)
email.setTemplate(pTemplateId);
email.openMail();
}
EmailUtils.openNewMail = function (pToContactId)
{
var params = {
"ContactId_param" : pToContactId
};
neon.openContext("Email", "EmailEdit_view", null, neon.OPERATINGSTATE_NEW, params);
}
/**
* object for handling emails
*
* @param {String|Array} [pToRecipients=[]] recipient email address or array of recipient email addresses
* @param {String} [pSender=null] email address of the sender
* @param {String} [pSubject=null] subject
* @param {String} [pBody=null] mail body
* @param {Array} [pCcRecipients=[]] array of recipient cc addresses
* @param {Array} [pBccRecipients=[]] array of recipient bcc addresses
*
* @class
*/
function Email (pToRecipients, pSender, pSubject, pBody, pCcRecipients, pBccRecipients)
{
if (pToRecipients && typeof(pToRecipients) == "string")
pToRecipients = [pToRecipients];
this.sender = pSender;
this.subject = pSubject;
this.body = pBody;
this.toRecipients = pToRecipients || [];
this.ccRecipients = pCcRecipients || [];
this.bccRecipients = pBccRecipients || [];
}
/**
* loads a document template into the mail body
*
* @param {String} pTemplateId the id of the template
*/
Email.prototype.setTemplate = function (pTemplateId)
{
var alias = "_____SYSTEMALIAS";
var binaryId = db.cell(SqlCondition.begin(alias)
.andPrepare("ASYS_BINARIES.ROW_ID", pTemplateId)
.buildSql("select ID from ASYS_BINARIES", "1=2"), alias
);
if (binaryId)
this.body = text.html2text(util.decodeBase64String(db.getBinaryContent(binaryId, alias)));
}
/**
* sets the sender of the mail
*
* @param {String} pContactId the contactId of the sender
*/
Email.prototype.setSender = function (pContactId)
{
this.sender = CommUtil.getStandardMail(pContactId);
}
/**
* generates a 'mailto:' URL from the email object
*/
Email.prototype.getMailtoUrl = function ()
{
var url = [];
if (this.toRecipients.length)
url.push("to=" + this.toRecipients.join());
if (this.ccRecipients.length)
url.push("cc=" + this.ccRecipients.join());
if (this.bccRecipients.length)
url.push("bcc=" + this.bccRecipients.join());
if (this.subject)
url.push("subject=" + this.subject);
if (this.body)
url.push("body=" + this.body);
url = "mailto:?" + url.join("&");
return encodeURI(url);
}
/**
* opens the email
*/
Email.prototype.openMail = function ()
{
neon.openUrl(this.getMailtoUrl(), false);
}
\ No newline at end of file
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