From 96557f28eca43ecc1372e1c5f4468748dde9e5ac Mon Sep 17 00:00:00 2001
From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local>
Date: Mon, 5 Aug 2019 09:14:26 +0200
Subject: [PATCH] libs documentation

---
 process/Bulkmail_lib/process.js         | 42 +++++++++++++++++++++++--
 process/DocumentTemplate_lib/process.js | 17 +++++++++-
 process/Email_lib/process.js            | 12 ++++---
 3 files changed, 63 insertions(+), 8 deletions(-)

diff --git a/process/Bulkmail_lib/process.js b/process/Bulkmail_lib/process.js
index 7e3fde56fb6..f7a62e37851 100644
--- a/process/Bulkmail_lib/process.js
+++ b/process/Bulkmail_lib/process.js
@@ -143,7 +143,11 @@ BulkMailUtils.sendBulkMail = function (pBulkMailId, pTestRecipients)
     };
 }
 
-
+/**
+ * opens a context to select a bulk mail to add recipients to
+ * 
+ * @param {String[]} pContactIds recipients that should be added
+ */
 BulkMailUtils.openAddRecipientView = function (pContactIds)
 {
     var params = {
@@ -216,6 +220,13 @@ BulkMailUtils.getBulkMailTemplate = function (pBulkMailId, pDocumentTemplateId)
     return template;
 }
 
+/**
+ * checks if a contact is a recipient of a bulk mail
+ * 
+ * @param {String} pBulkMailId bulkmail id
+ * @param {String} pContactId contact id
+ * @return {boolean} true, if the contact is a recipient
+ */
 BulkMailUtils.isRecipient = function (pBulkMailId, pContactId)
 {
     return db.cell(SqlCondition.begin()
@@ -225,6 +236,11 @@ BulkMailUtils.isRecipient = function (pBulkMailId, pContactId)
     ) != "0";
 }
 
+/**
+ * opens the BulkMail context in new mode
+ * 
+ * @param {String[]} [pRecipients] recipients that should be added after creation
+ */
 BulkMailUtils.newBulkMail = function (pRecipients)
 {
     var params = {
@@ -233,6 +249,14 @@ BulkMailUtils.newBulkMail = function (pRecipients)
     neon.openContext("BulkMail", "BulkMailEdit_view", null, neon.OPERATINGSTATE_NEW, params);
 }
 
+/**
+ * Filters the given contactIds if they can be added as new recipients.
+ * Checks if a contact is already a recipient or if there is a advertising ban.
+ * 
+ * @param {String} pBulkMailId id of the bulk mail the contacts should be added to
+ * @param {String[]} pContactIds contacts to filter
+ * @return {String[]} contacts that can be added as recipients
+ */
 BulkMailUtils.filterNewRecipients = function (pBulkMailId, pContactIds)
 {
     var existsQuery = "not exists(select BULKMAILRECIPIENTID from BULKMAILRECIPIENT where BULKMAILRECIPIENT.CONTACT_ID = CONTACT.CONTACTID and # = ?)";
@@ -245,6 +269,9 @@ BulkMailUtils.filterNewRecipients = function (pBulkMailId, pContactIds)
     return db.array(db.COLUMN, query); 
 }
 
+/**
+ * opens the given bulk mail
+ */
 BulkMailUtils.openBulkMail = function (pBulkMailId)
 {
     neon.openContext("BulkMail", "BulkMailMain_view", [pBulkMailId], neon.OPERATINGSTATE_VIEW, null);
@@ -273,7 +300,11 @@ SerialLetterUtils.addRecipients = function (pSerialLetterId, pContactIds)
     db.inserts(inserts);
 }
 
-
+/**
+ * opens a context to select a serial letter to add recipients to
+ * 
+ * @param {String[]} pContactIds recipients that should be added
+ */
 SerialLetterUtils.openAddRecipientView = function (pContactIds)
 {
     var params = {
@@ -297,6 +328,13 @@ SerialLetterUtils.buildSerialLetter = function (pSerialLetterId, pRecipientIds)
     });
 }
 
+/**
+ * checks if a contact is a recipient of a serial letter
+ * 
+ * @param {String} pSerialLetterId serial letter id
+ * @param {String} pContactId contact id
+ * @return {boolean} true, if the contact is a recipient
+ */
 SerialLetterUtils.isRecipient = function (pSerialLetterId, pContactId)
 {
     return db.cell(SqlCondition.begin()
diff --git a/process/DocumentTemplate_lib/process.js b/process/DocumentTemplate_lib/process.js
index 121ae9d04a7..4434b77bb3e 100644
--- a/process/DocumentTemplate_lib/process.js
+++ b/process/DocumentTemplate_lib/process.js
@@ -29,6 +29,13 @@ import("Email_lib");
 var DocumentTemplate = (function ()
 {
 
+/**
+ * constructor for DocumentTemplate
+ * 
+ * @param {String} pTemplateContent content, as base64 string (except for DocumentTemplate.types.PLAIN, then it's a normal string)
+ * @param {String} pType type of the template, use the DocumentTemplate.types constants here
+ * @param {String} [pFilename] file name of the template 
+ */
 function DocumentTemplate (pTemplateContent, pType, pFilename)
 {
     this.content = pTemplateContent;
@@ -36,6 +43,9 @@ function DocumentTemplate (pTemplateContent, pType, pFilename)
     this.filename = pFilename;
 }
 
+/**
+ * @return {String} the text of the content
+ */
 DocumentTemplate.prototype.toString = function ()
 {
     if (this.type == DocumentTemplate.types.PLAIN)
@@ -265,7 +275,7 @@ DocumentTemplate.prototype.getReplacedEmailsByContactIds = function (pContactIds
 }
 
 /**
- * Provides functions for the DocumentTemplate object.
+ * Provides functions for the DocumentTemplate object that aren't accessible from outside
  */
 function TemplateHelper () {}
 /**
@@ -505,6 +515,11 @@ TemplateHelper._getReplacedDOCX = function (pTemplate, pReplacements)
  */
 function LetterUtils () {}
 
+/**
+ * opens a new letter
+ * 
+ * @param {String} pContactId id of the contact to fetch the data from
+ */
 LetterUtils.openNewLetter = function (pContactId)
 {
     var params = {
diff --git a/process/Email_lib/process.js b/process/Email_lib/process.js
index 4c6a8af91fc..5bb71a3a699 100644
--- a/process/Email_lib/process.js
+++ b/process/Email_lib/process.js
@@ -20,7 +20,6 @@ function EmailWritingUtils () {}
  * @param {String} pSenderContactId contactId of the sender. the standard mailadress of the contact is used as sender-address
  * @param {String} [pTemplateId] if a document-template shall be used, give the templateId here
  * @param {String} [pRecipientContactId] contactId of the recipient, required to fill placeholders
- * 
  * @return {Array} the eml document as array with [filename, base64]
  */
 EmailWritingUtils.openMailTemplate = function (pToRecipients, pSenderContactId, pTemplateId, pRecipientContactId)
@@ -59,7 +58,6 @@ EmailWritingUtils.openNewMail = function (pToContactId, pToEmailAddress)
  * @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)
@@ -76,7 +74,10 @@ function Email (pToRecipients, pSender, pSubject, pBody, pCcRecipients, pBccReci
 }
 
 /**
- * makes an Email object from a RFC mail (base64 encoded)
+ * makes an Email object from a RFC
+ * 
+ * @param {String} pBase64RFC the RFC mail, base64 encoded
+ * @return {Email} a new Email object
  */
 Email.fromRFC = function (pBase64RFC)
 {
@@ -186,7 +187,6 @@ Email.prototype.getRFCmail = function ()
     //X-Uniform-Type-Identifier: com.apple.mail-draft
     //this could be added later if needed
 
-   
     var mailObj = mail.getCachedMail(mailId);
     return mail.toRFC(mailObj);
 }
@@ -201,6 +201,8 @@ Email.prototype.openMail = function ()
 
 /**
  * ask for a download of the email
+ * 
+ * @return {Array} array of [filename, EML (base64)]
  */
 Email.prototype.downloadEML = function ()
 {
@@ -211,7 +213,7 @@ Email.prototype.downloadEML = function ()
 }
 
 /**
- * returns a eml as (base64 encoded)
+ * @return {String} RFC mail (base64 encoded)
  */
 Email.prototype.getEML = function()
 {
-- 
GitLab