Skip to content
Snippets Groups Projects
Commit 19eb89cb authored by David Büchler's avatar David Büchler
Browse files

Beginn implementierung Serienaktion mit condition

parent bde39a6e
No related branches found
No related tags found
No related merge requests found
Showing
with 137 additions and 63 deletions
......@@ -38,7 +38,7 @@
<valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignparticipantmessage/valueProcess.js</valueProcess>
</entityField>
<entityParameter>
<name>campaignParticipants_param</name>
<name>campaignParticipantsRowIds_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
......@@ -115,6 +115,14 @@
<name>isUpdate</name>
<valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/isupdate/valueProcess.js</valueProcess>
</entityField>
<entityParameter>
<name>campaignParticipantsCondition_param</name>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>dataSourceTableName_param</name>
<expose v="true" />
</entityParameter>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
......
import("system.logging");
import("system.result");
import("system.translate");
import("system.vars");
var campaignParticipantsAmount = JSON.parse(vars.getString("$param.campaignParticipants_param")).length;
var informationText = translate.text("participants will be added to the selected campaign step");
//logging.log(" -> " + JSON.stringify(vars.getString("$param.campaignParticipantsRowIds_param")));
//var test = vars.getString("$param.campaignParticipantsRowIds_param");
//var campaignParticipantsAmount = JSON.parse(vars.getString("$param.campaignParticipantsRowIds_param")).length;
//var informationText = translate.text("participants will be added to the selected campaign step");
result.string(campaignParticipantsAmount + " " + informationText);
\ No newline at end of file
//result.string(campaignParticipantsAmount + " " + informationText);
result.string("Message");
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.db");
import("system.util");
import("Campaign_lib");
var cols = [];
var participantRowIds = JSON.parse(vars.getString("$param.campaignParticipantsRowIds_param"));
var participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param"));
var conditionSourceTableName = vars.getString("$param.dataSourceTableName_param");
var campaignId = vars.getString("$field.CAMPAIGN_ID");
var newCampaignStepId = vars.getString("$field.CAMPAIGNSTEP_ID");
var participants = JSON.parse(vars.getString("$param.campaignParticipants_param"));
var isUpdate = vars.get("$field.isUpdate");
var colNamesCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnNames();
var cols = [];
var colNamesCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnNames();
if(isUpdate == "true")
if(participantRowIds.length > 0)
{
cols = [ "CAMPAIGNSTEP_ID",
"USER_EDIT",
"DATE_EDIT"
];
_handleRowIds(participantRowIds);
}
else
{
cols = [ "CAMPAIGNPARTICIPANTID"
,"CONTACT_ID"
,"CAMPAIGN_ID"
,"CAMPAIGNSTEP_ID"
,"USER_NEW"
,"DATE_NEW"
];
_handleCondition(participantCondition, conditionSourceTableName)
}
function _handleCondition(pCondition, pSourceTableName)
{
//( UPPER( PERSON.SALUTATION ) = UPPER( 'Frau' )
}
var statementArray = [];
var logArray = [];
for (participant in participants)
function _handleRowIds(pParticipantRowIds)
{
var campaignParticipantLogId = util.getNewUUID();
if(isUpdate == "true")
{
let updatedValues = [newCampaignStepId,
vars.get("$sys.user"),
vars.get("$sys.date")];
let condition = "CAMPAIGNPARTICIPANTID = '" + participants[participant] + "'";
let valsCampaignParticipantLog = new Array(participants[participant], campaignId, newCampaignStepId, campaignParticipantLogId, vars.get("$sys.user"), vars.get("$sys.date"));
statementArray.push(["CAMPAIGNPARTICIPANT", cols, null, updatedValues, condition]);
logArray.push(["CAMPAIGNPARTICIPANTLOG", colNamesCampaignParticipantLog, null, valsCampaignParticipantLog]);
cols = [ "CAMPAIGNSTEP_ID",
"USER_EDIT",
"DATE_EDIT"
];
}
else
{
let campaignParticipantId = util.getNewUUID();
var valsCampaignParticipant = [ campaignParticipantId
, participants[participant]
, campaignId
, newCampaignStepId
, vars.get("$sys.user")
, vars.get("$sys.date")
cols = [ "CAMPAIGNPARTICIPANTID"
,"CONTACT_ID"
,"CAMPAIGN_ID"
,"CAMPAIGNSTEP_ID"
,"USER_NEW"
,"DATE_NEW"
];
}
let valsCampaignParticipantLog = new Array(campaignParticipantId, campaignId, newCampaignStepId, campaignParticipantLogId, vars.get("$sys.user"), vars.get("$sys.date"));
let statementArray = [];
let logArray = [];
for (participant in pParticipantRowIds)
{
let campaignParticipantLogId = util.getNewUUID();
if(isUpdate == "true")
{
let updatedValues = [newCampaignStepId,
vars.get("$sys.user"),
vars.get("$sys.date")];
let condition = "CAMPAIGNPARTICIPANTID = '" + pParticipantRowIds[participant] + "'";
let valsCampaignParticipantLog = new Array(pParticipantRowIds[participant], campaignId, newCampaignStepId, campaignParticipantLogId, vars.get("$sys.user"), vars.get("$sys.date"));
statementArray.push(["CAMPAIGNPARTICIPANT", cols, null, updatedValues, condition]);
logArray.push(["CAMPAIGNPARTICIPANTLOG", colNamesCampaignParticipantLog, null, valsCampaignParticipantLog]);
}
else
{
let campaignParticipantId = util.getNewUUID();
let valsCampaignParticipant = [ campaignParticipantId
, pParticipantRowIds[participant]
, campaignId
, newCampaignStepId
, vars.get("$sys.user")
, vars.get("$sys.date")
];
let valsCampaignParticipantLog = new Array(campaignParticipantId, campaignId, newCampaignStepId, campaignParticipantLogId, vars.get("$sys.user"), vars.get("$sys.date"));
statementArray.push(["CAMPAIGNPARTICIPANT", cols, null, valsCampaignParticipant]);
logArray.push(["CAMPAIGNPARTICIPANTLOG", colNamesCampaignParticipantLog, null, valsCampaignParticipantLog]);
statementArray.push(["CAMPAIGNPARTICIPANT", cols, null, valsCampaignParticipant]);
}
}
if(isUpdate == "true")
db.updates(statementArray)
else
db.inserts(statementArray);
if(logArray.length > 0)
db.inserts(logArray);
}
if(isUpdate == "true")
db.updates(statementArray)
else
db.inserts(statementArray);
db.inserts(logArray);
\ No newline at end of file
......@@ -2,7 +2,10 @@ import("system.vars");
import("system.neon");
import("Campaign_lib");
if(vars.exists("$sys.selection")) //selektierte IDs als Array
var sysSelection = vars.getString("$sys.selection");
if(sysSelection.length > 0) //selektierte IDs als Array
{
CampaignUtils.openSetCampaignStepView(vars.getString("$sys.selection"), vars.get("$field.CAMPAIGN_ID"), vars.get("$field.CAMPAIGNSTEP_ID"));
}
\ No newline at end of file
......@@ -2,7 +2,14 @@ import("system.vars");
import("system.neon");
import("Campaign_lib");
if(vars.exists("$sys.selection")) //selektierte IDs als Array
var sysSelection = vars.getString("sys.selection");
if(sysSelection.length > 0) //selektierte IDs als Array
{
CampaignUtils.addParticipantsByRowIds(sysSelection, "ORGANISATION");
}
else
{
CampaignUtils.addParticipants(vars.getString("$sys.selection"));
let sysFilter = vars.get("$sys.filter");//todo change name
CampaignUtils.addParticipantsByCondition(sysFilter.condition, "ORGANISATION");
}
\ No newline at end of file
......@@ -2,7 +2,20 @@ import("system.vars");
import("system.neon");
import("Campaign_lib");
if(vars.exists("$sys.selection")) //selektierte IDs als Array
/*
* If there's a selection only those are ought to be added.
* Otherwise the filter gets checked, if a filter has beed set, the condition
* is used to determine the objects to be added.
* If no selection has been set, all objects will be added.
*/
var sysSelection = vars.getString("$sys.selection");
if(sysSelection.length > 0) //selektierte IDs als Array
{
CampaignUtils.addParticipantsByRowIds(sysSelection, "PERSON");
}
else
{
CampaignUtils.addParticipants(vars.getString("$sys.selection"));
let sysFilter = vars.get("$sys.filter");//todo change name
CampaignUtils.addParticipantsByCondition(sysFilter.condition, "PERSON");
}
\ No newline at end of file
......@@ -3702,6 +3702,9 @@
<entry>
<key>Do you really want to delete this recurring appointment?</key>
</entry>
<entry>
<key>Start date</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
<sqlModels>
......
......@@ -4523,6 +4523,7 @@
</entry>
<entry>
<key>New step</key>
<value>Neue Stufe</value>
</entry>
<entry>
<key>Runtime</key>
......
......@@ -3751,6 +3751,9 @@
<entry>
<key>Do you really want to delete this recurring appointment?</key>
</entry>
<entry>
<key>Start date</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
</language>
......@@ -3,7 +3,6 @@
<name>CampaignStep</name>
<title>Campaign Step</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<mainview>CampaignStepMain_view</mainview>
<filterview>CampaignStepFilter_view</filterview>
<editview>CampaignStepEdit_view</editview>
<preview>CampaignStepPreview_view</preview>
......
......@@ -30,11 +30,22 @@ CampaignUtils.addParticipant = function(pContactId)
*
* @param {String} pRowIds req ContactIds
*/
CampaignUtils.addParticipants = function(pRowIds)
CampaignUtils.addParticipantsByRowIds = function(pRowIds, pSourceTableName)
{
_CampaignUtils._openAddParticipantContext("CampaignAddParticipants", pRowIds, "campaignParticipants_param", "CampaignAddParticipantsEdit_view");
_CampaignUtils._openAddParticipantContext("CampaignAddParticipants", pRowIds,
"campaignParticipantsRowIds_param", "CampaignAddParticipantsEdit_view", pSourceTableName);
}
/**
* Add many Contacts (Person or Organistaion) to a Campaign
*
* @param {String} pRowIds req ContactIds
*/
CampaignUtils.addParticipantsByCondition = function(pCondition, pSourceTableName)
{
_CampaignUtils._openAddParticipantContext("CampaignAddParticipants", pCondition,
"campaignParticipantsCondition_param", "CampaignAddParticipantsEdit_view", pSourceTableName);
}
/**
* todo
......@@ -149,8 +160,7 @@ CampaignUtils.getParticipantLogInsertColumnNames = function()
CampaignUtils.openSetCampaignStepView = function(pParticipantIds, pCampaignId, pCampaignStepId)
{
var params = {};
params["campaignParticipants_param"] = pParticipantIds;
params["campaignParticipantsRowIds_param"] = pParticipantIds;
params["currentCampaignId_param"] = pCampaignId;
params["currentCampaignStepId_param"] = pCampaignStepId;
params["isUpdate_param"] = true;
......@@ -311,15 +321,16 @@ function _CampaignUtils() {}
* @param {String} pView req targeting view
*
*/
_CampaignUtils._openAddParticipantContext = function(pContext, pRowIds, pEntityParam, pView)
_CampaignUtils._openAddParticipantContext = function(pContext, pTargetDataExpression, pDataExpressionParameterName, pView, pSourceTableName)
{
var params = {};
if (pRowIds)
if (pTargetDataExpression)
{
params[pEntityParam] = pRowIds;
params[pDataExpressionParameterName] = pTargetDataExpression;
}
params["isUpdate_param"] = false;
params["dataSourceTableName_param"] = pSourceTableName;
neon.openContext(pContext, null, null, neon.OPERATINGSTATE_NEW, params);
}
......
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