From 87a3a314316a6c89b577b600be0c0df2ddbd3d6f Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Tue, 10 Sep 2019 15:25:36 +0200
Subject: [PATCH] Bulkmail: work around initialisation of editor directly after
 save which is bad for a long eml file

---
 entity/BulkMail_entity/entityfields/content/stateProcess.js | 4 ++++
 entity/BulkMail_entity/entityfields/subject/valueProcess.js | 4 ++--
 .../entityfields/subjectpreview/valueProcess.js             | 6 +++---
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/entity/BulkMail_entity/entityfields/content/stateProcess.js b/entity/BulkMail_entity/entityfields/content/stateProcess.js
index 618982924de..6911573910a 100644
--- a/entity/BulkMail_entity/entityfields/content/stateProcess.js
+++ b/entity/BulkMail_entity/entityfields/content/stateProcess.js
@@ -9,5 +9,9 @@ if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_VIEW &&
 {
     result.string(neon.COMPONENTSTATE_INVISIBLE);
 }
+// keep in invisible mode to prevent a visible editor directly after save which needs much time to initiate (for eml)
+// somehow the edit view is in view mode and the editor doesn't know anything about it and initializes itself...
+else if (vars.get("$context.currentTemplateType") == DocumentTemplate.types.EML || vars.get("$context.currentTemplateType") == DocumentTemplate.types.HTML)
+    result.string(neon.COMPONENTSTATE_INVISIBLE);
 else
     result.string(neon.COMPONENTSTATE_EDITABLE);
\ No newline at end of file
diff --git a/entity/BulkMail_entity/entityfields/subject/valueProcess.js b/entity/BulkMail_entity/entityfields/subject/valueProcess.js
index 757195e1284..23c099c4dd8 100644
--- a/entity/BulkMail_entity/entityfields/subject/valueProcess.js
+++ b/entity/BulkMail_entity/entityfields/subject/valueProcess.js
@@ -4,10 +4,10 @@ import("Document_lib");
 import("DocumentTemplate_lib");
 import("system.neon");
 import("system.vars");
-
+/*
 if (vars.get("$this.value") == null && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
 {
     var upload = new FileUpload(vars.get("$field.bindata"));
     if (upload.isFilled() && DocumentTemplate.types.fromMimeType(upload.mimeType) == DocumentTemplate.types.EML)
         result.string(Email.fromRFC(upload.bindata).subject);
-}
\ No newline at end of file
+}*/
\ No newline at end of file
diff --git a/entity/BulkMail_entity/entityfields/subjectpreview/valueProcess.js b/entity/BulkMail_entity/entityfields/subjectpreview/valueProcess.js
index 6db9b03be72..ee4242c53a3 100644
--- a/entity/BulkMail_entity/entityfields/subjectpreview/valueProcess.js
+++ b/entity/BulkMail_entity/entityfields/subjectpreview/valueProcess.js
@@ -3,7 +3,7 @@ import("system.vars");
 import("system.result");
 import("DocumentTemplate_lib");
 
-var template = new DocumentTemplate(vars.get("$field.SUBJECT"), DocumentTemplate.types.PLAIN);
-var subject = template.getReplacedContentByContactId(EmployeeUtils.getCurrentContactId());
+//var template = new DocumentTemplate(vars.get("$field.SUBJECT"), DocumentTemplate.types.PLAIN);
+//var subject = template.getReplacedContentByContactId(EmployeeUtils.getCurrentContactId());
 
-result.string(subject);
\ No newline at end of file
+result.string("test");
\ No newline at end of file
-- 
GitLab