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

Bulkmail editing the content

parent 6344597c
No related branches found
No related tags found
No related merge requests found
import("system.neon");
import("Document_lib");
import("system.util");
import("system.result");
import("system.vars");
import("system.db");
import("DocumentTemplate_lib");
import("Bulkmail_lib");
if (!vars.get("$this.value"))
if (vars.get("$this.value") == null)
{
var upload = vars.get("$field.BINDATA");
var template;
......@@ -14,20 +16,13 @@ if (!vars.get("$this.value"))
var binData = DocumentUtil.getBindataFromUpload(upload);
var filename = DocumentUtil.getFilenameFromUpload(upload);
var type = DocumentUtil.getFileExtensionFromUpload(filename);
type = ({
"txt" : DocumentTemplate.types.TXT,
"html" : DocumentTemplate.types.HTML,
"htm" : DocumentTemplate.types.HTML,
"eml" : DocumentTemplate.types.EML
})[type];
template = new DocumentTemplate(binData, type);
template = new DocumentTemplate(binData, DocumentTemplate.types.fromFileExtension(type));
}
else
{
template = DocumentTemplate.loadTemplate(vars.get("$field.DOCUMENTTEMPLATE_ID"));
template = BulkMailUtils.getBulkMailTemplate(vars.get("$field.BULKMAILID"), vars.get("$field.DOCUMENTTEMPLATE_ID"));
}
var content = template.getReplacedContent({}, true);
result.string(content);
}
}
\ No newline at end of file
import("Sql_lib");
import("system.result");
import("system.vars");
import("system.db");
import("system.util");
import("Document_lib");
//TODO - Function
var upload = vars.get("$field.BINDATA");
var bindataUpload = DocumentUtil.getBindataFromUpload(upload);
var filename = "";
var bindata = "";
if(bindataUpload != "")
{
filename = DocumentUtil.getFilenameFromUpload(upload);
bindata = bindataUpload;
}
if(bindata != "" && filename != "")
{
let sysAlias = "_____SYSTEMALIAS";
var binaryId = db.cell(SqlCondition.begin(sysAlias)
.andPrepareVars("ASYS_BINARIES.ROW_ID", "$field.BULKMAILID")
.buildSql("select ID from ASYS_BINARIES", "1=2"), sysAlias);
db.updateBinary(binaryId, "", bindata, filename, "", "", sysAlias);
}
\ No newline at end of file
import("system.neon");
import("Sql_lib");
import("DocumentTemplate_lib");
import("system.result");
import("system.vars");
import("system.db");
import("system.util");
import("Document_lib");
import("Bulkmail_lib");
//TODO - Function
var content = vars.get("$field.content");
var originalBinData = vars.get("$field.BINDATA");
var filename, type, template;
if(vars.get("$field.BINDATA"))
{
filename = DocumentUtil.getFilenameFromUpload(vars.get("$field.BINDATA"));
type = DocumentUtil.getFileExtensionFromUpload(filename);
type = DocumentTemplate.types.fromFileExtension(type);
}
else
{
template = BulkMailUtils.getBulkMailTemplate(vars.get("$field.BULKMAILID"), vars.get("$field.DOCUMENTTEMPLATE_ID"));
type = template.type;
}
if (type == DocumentTemplate.types.EML || type == DocumentTemplate.types.HTML)
content = "<html>" + content + "</html>";
var bindata = util.encodeBase64String(content);
if (!filename)
filename = vars.get("$field.NAME") + ".txt";
if(bindata != "")
{
let sysAlias = "_____SYSTEMALIAS";
var binaryId = db.cell(SqlCondition.begin(sysAlias)
.andPrepareVars("ASYS_BINARIES.ROW_ID", "$field.BULKMAILID")
.buildSql("select ID from ASYS_BINARIES", "1=2"), sysAlias);
db.updateBinary(binaryId, "", bindata, filename, "", "", sysAlias);
neon.refresh(["$field.content"]);
}
......@@ -771,6 +771,8 @@
<entityActionField>
<name>addToSerialLetter</name>
<onActionProcess>%aditoprj%/entity/Organisation_entity/entityfields/campaignactiongroup/children/addtoserialletter/onActionProcess.js</onActionProcess>
<isObjectAction v="false" />
<isSelectionAction v="true" />
<iconId>VAADIN:ENVELOPES</iconId>
</entityActionField>
</children>
......
......@@ -6328,6 +6328,7 @@
</entry>
<entry>
<key>Download letter</key>
<value>Brief herunterladen</value>
</entry>
<entry>
<key>Phase progression</key>
......
......@@ -27,7 +27,7 @@
</neonViewReference>
<neonViewReference>
<name>6b057fb0-94ac-4bca-88b2-c97fdfcf9d6e</name>
<view>BulkMailTest_view</view>
<view>BulkMailContent_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>BulkMailTest_view</name>
<title>Preview</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<layout>
<noneLayout>
<name>layout</name>
</noneLayout>
</layout>
<children>
<genericViewTemplate>
<name>Subject</name>
<showDrawer v="true" />
<drawerCaption>Subject</drawerCaption>
<fixedDrawer v="true" />
<hideLabels v="true" />
<entityField>#ENTITY</entityField>
<fields>
<entityFieldLink>
<name>d85c2b49-3a32-4261-95aa-6e13d9debe46</name>
<entityField>subjectPreview</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
<genericViewTemplate>
<name>Body</name>
<showDrawer v="true" />
<drawerCaption>Content</drawerCaption>
<fixedDrawer v="true" />
<hideLabels v="true" />
<entityField>#ENTITY</entityField>
<fields>
<entityFieldLink>
<name>af0d45a2-a96f-4031-a93d-62ac177efb43</name>
<entityField>content</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
</children>
</neonView>
<?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>BulkMailContent_view</name>
<title>Content</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<layout>
<noneLayout>
<name>layout</name>
</noneLayout>
</layout>
<children>
<genericViewTemplate>
<name>Subject</name>
<showDrawer v="true" />
<drawerCaption>Subject</drawerCaption>
<fixedDrawer v="true" />
<hideLabels v="true" />
<entityField>#ENTITY</entityField>
<fields>
<entityFieldLink>
<name>d85c2b49-3a32-4261-95aa-6e13d9debe46</name>
<entityField>subjectPreview</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
<genericViewTemplate>
<name>Body</name>
<showDrawer v="true" />
<drawerCaption>Content</drawerCaption>
<fixedDrawer v="true" />
<hideLabels v="true" />
<entityField>#ENTITY</entityField>
<fields>
<entityFieldLink>
<name>af0d45a2-a96f-4031-a93d-62ac177efb43</name>
<entityField>content</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
</children>
</neonView>
......@@ -22,7 +22,7 @@
<neonViewReference>
<name>3222ace8-c6d6-4dab-ada1-1f50b983e7e7</name>
<entityField>#ENTITY</entityField>
<view>BulkMailTest_view</view>
<view>BulkMailContent_view</view>
</neonViewReference>
</children>
</neonView>
......@@ -52,7 +52,42 @@ DocumentTemplate.types = {
EML : "eml",
ODT : "odt",
DOCX : "docx",
PLAIN : "plain" //for simple strings
PLAIN : "plain", //for simple strings
fromFileExtension : function (pFileExtension)
{
switch (pFileExtension)
{
case "html":
case "htm":
return this.HTML;
case "eml":
return this.EML;
case "odt":
return this.ODT;
case "docx":
return this.DOCX;
case "txt":
default:
return this.TXT;
}
},
fromMimetype : function (pMimetype)
{
switch (pMimetype)
{
case "text/html":
return this.HTML;
case "message/rfc822":
return this.EML;
case "application/vnd.oasis.opendocument.text":
return this.ODT;
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
return this.DOCX;
case "text/plain":
default:
return this.TXT;
}
}
};
/**
......@@ -76,16 +111,7 @@ DocumentTemplate.loadTemplate = function (pAssignmentRowId, pAssignmentTable)
var binaryId = templateDocument[0][db.BINARY_ID];
var filename = templateDocument[0][db.BINARY_FILENAME];
var mimetype = templateDocument[0][db.BINARY_MIMETYPE];
var typeMap = {
"text/plain" : DocumentTemplate.types.TXT,
"text/html" : DocumentTemplate.types.HTML,
"message/rfc822" : DocumentTemplate.types.EML,
"application/vnd.oasis.opendocument.text" : DocumentTemplate.types.ODT,
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" : DocumentTemplate.types.DOCX
};
var type = typeMap[mimetype];
if (type === undefined)
throw new Error("Invalid mime type for document template");
var type = DocumentTemplate.types.fromMimetype(mimetype);
return new DocumentTemplate(db.getBinaryContent(binaryId, alias), type, filename);
}
......
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