Skip to content
Snippets Groups Projects
Commit 2b1e8612 authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

[Projekt: Entwicklung - Neon][TicketNr.: 1029627][Preview Kontakt: Standard-Kommunikationsadresse]

parent bdee3383
No related branches found
No related tags found
No related merge requests found
......@@ -378,6 +378,11 @@
<title>standard email</title>
<outgoingField>OrgCommEmail_dfo</outgoingField>
<onValueChange>%aditoprj%/entity/Org_entity/entityfields/standard_email_comm/onValueChange.js</onValueChange>
<onValueChangeTypes>
<element>MASK</element>
<element>PROCESS</element>
<element>RECORD</element>
</onValueChangeTypes>
</entityField>
<entityField>
<name>STANDARD_PHONE_COMM</name>
......
import("system.vars");
import("system.neon");
import("Entity_lib");
// TODO: also there is currently no good way to do updates with fields not connected to the record container. Workaround: imagevariable and update in onDBUpdate Process
if (vars.get("$field.IMAGE"))
{
vars.set("$image.changedImage", true);
}
else
{
vars.set("$image.changedImage", "deleted");
}
FieldChanges.setChange("$field.IMAGE");
\ No newline at end of file
import("system.vars");
import("system.neon");
import("Entity_lib");
// TODO: also there is currently no good way to do updates with fields not connected to the record container. Workaround: imagevariable and update in onDBUpdate Process
if (vars.get("$field.STANDARD_EMAIL_COMM"))
{
vars.set("$image.changedStandardEmail", true);
}
else
{
vars.set("$image.changedStandardEmail", "deleted");
}
FieldChanges.setChange("$field.STANDARD_EMAIL_COMM");
\ No newline at end of file
import("system.vars");
import("system.neon");
import("Entity_lib");
// TODO: also there is currently no good way to do updates with fields not connected to the record container. Workaround: imagevariable and update in onDBUpdate Process
if (vars.get("$field.STANDARD_PHONE_COMM"))
{
vars.set("$image.changedStandardPhone", true);
}
else
{
vars.set("$image.changedStandardPhone", "deleted");
}
FieldChanges.setChange("$field.STANDARD_PHONE_COMM");
\ No newline at end of file
import("system.vars");
import("Org_lib");
import("Comm_lib");
import("Entity_lib");
// TODO: this is a workaround for missing possibility to react on changes of fields not connected to record Contqainer
if (vars.exists("$image.changedImage"))
{
if (vars.get("$image.changedImage"))
{
var imageData = vars.getString("$field.IMAGE");
if (vars.get("$image.changedImage") != "deleted")
{
OrgUtils.setImage(vars.get("$field.ORGID"), imageData);
}
else
{
OrgUtils.removeImage(vars.get("$field.ORGID"));
}
}
}
FieldChanges.assimilateChangeAndDispose("$field.IMAGE", function(state, value){
if (state == FieldChanges.STATE_CHANGED())
OrgUtils.setImage(vars.get("$field.ORGID"), value);
else
OrgUtils.removeImage(vars.get("$field.ORGID"));
});
var uid = vars.get("$sys.uid");
vars.set("$image.changedImage", false);
if (vars.exists("$image.changedStandardEmail"))
{
if (vars.get("$image.changedStandardEmail"))
{
if (vars.get("$image.changedStandardEmail") != "deleted")
{
CommUtil.setStandardMail(uid, vars.get("$field.STANDARD_EMAIL_COMM"));
}
else
{
//TODO: implement
}
}
}
vars.set("$image.changedStandardEmail", false);
if (vars.exists("$image.changedStandardPhone"))
{
if (vars.get("$image.changedStandardPhone"))
{
if (vars.get("$image.changedStandardPhone") != "deleted")
{
CommUtil.setStandardMail(uid, vars.get("$field.STANDARD_PHONE_COMM"));
}
else
{
//TODO: implement
}
}
}
var uid = vars.get("$sys.uid");
FieldChanges.assimilateChangeAndDispose("$field.STANDARD_EMAIL_COMM", function(state, value){
CommUtil.setStandardMail(uid, value);
});
vars.set("$image.changedStandardPhone", false);
FieldChanges.assimilateChangeAndDispose("$field.STANDARD_PHONE_COMM", function(state, value){
CommUtil.setStandardPhone(uid, value);
});
......@@ -34,13 +34,14 @@ CommUtil.getMediumIdsByCategory = function (pCategory)
* sets the standard address for COMM entries for a specific category;
* does not verify if the COMMID you provide has the given category
* @param {String} pAffectedRowId a refencial ID whoes COMMs should be modified (a RELATIONID)
* @param {String} pNewStandardCommId COMMID of the new STANDARD comm-entry
* @param {String} pNewStandardCommId COMMID of the new STANDARD comm-entry; can be an empty string if no new standard adress shall be set but the old standard removed
* @param {String} pCategory value of the keyword "COMM.MEDIUM" custom.category; e.g. "PHONE"; the STANDARD of this category is set
* @return {null} currently returns always null; reserved for future
*/
CommUtil.setStandardForCategory = function(pAffectedRowId, pNewStandardCommId, pCategory)
{
if (!pAffectedRowId || !pNewStandardCommId || !pCategory)
//pNewStandardCommId can be an empty string if the standard has to be removed
if (!pAffectedRowId || pNewStandardCommId == undefined || !pCategory)
return null;
var mediumIds = CommUtil.getMediumIdsByCategory(pCategory);
if (mediumIds.length == 0)//none found? since mediumIds affects the update later there is no reason to continue
......@@ -58,12 +59,16 @@ CommUtil.setStandardForCategory = function(pAffectedRowId, pNewStandardCommId, p
cond.and("MEDIUM_ID in (" + mediumIds.join(", ") + ")");
statements.push(["COMM", cols, types, ["0", timestamp, login], cond.build()]);
//set the new standard comm-record
cond.clear();
//check commid, relId and medium to prevent data-inconsistency when bad function params are passed by (e.g commid of a different category)
cond.andPrepare("COMM.COMMID", pNewStandardCommId).andPrepare("COMM.RELATION_ID", pAffectedRowId);
cond.and("MEDIUM_ID in (" + mediumIds.join(", ") + ")");
statements.push(["COMM", cols, types, ["1", timestamp, login], cond.build()]);
//pNewStandardCommId can be an empty string if the standard has to only be removed
if (pNewStandardCommId != "")
{
//set the new standard comm-record
cond.clear();
//check commid, relId and medium to prevent data-inconsistency when bad function params are passed by (e.g commid of a different category)
cond.andPrepare("COMM.COMMID", pNewStandardCommId).andPrepare("COMM.RELATION_ID", pAffectedRowId);
cond.and("MEDIUM_ID in (" + mediumIds.join(", ") + ")");
statements.push(["COMM", cols, types, ["1", timestamp, login], cond.build()]);
}
count = db.updates(statements);
return null;
......
......@@ -51,4 +51,60 @@ ProcessHandlingUtils.initialParamToResult = function(pParamVarName)
}
}
}
\ No newline at end of file
}
//TODO: comment
function FieldChanges(){}
FieldChanges.STATE_NO_CHANGE = function (){
return "NO_CHANGE"
};
FieldChanges.STATE_CHANGED = function (){
return "CHANGED"
};
FieldChanges.STATE_DELETED = function (){
return "DELETED"
};
FieldChanges.assimilateChangeAndDispose = function (pFieldName, pAssimilatorFn)
{
var allChanges = FieldChanges._getStorage();
if (allChanges[pFieldName] == undefined)
return null;
var res = null;
if (allChanges[pFieldName].state != FieldChanges.STATE_NO_CHANGE())
{
res = pAssimilatorFn.call(this, allChanges[pFieldName].state, vars.get(pFieldName));
allChanges[pFieldName].state = FieldChanges.STATE_NO_CHANGE();
FieldChanges._setStorage(allChanges);
}
return res;
};
FieldChanges.setChange = function(pFieldName)
{
var allChanges = FieldChanges._getStorage();
if (allChanges[pFieldName] == undefined)
allChanges[pFieldName] = {};
var value = vars.get(pFieldName);
if (!value)
allChanges[pFieldName].state = FieldChanges.STATE_DELETED();
else
allChanges[pFieldName].state = FieldChanges.STATE_CHANGED();
FieldChanges._setStorage(allChanges);
};
FieldChanges._getStorage = function()
{
if (!vars.exists("$image.FieldChanges"))
return {};
return vars.get("$image.FieldChanges");
};
FieldChanges._setStorage = function(pAllChanges)
{
return vars.set("$image.FieldChanges", pAllChanges);
};
\ 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