diff --git a/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod b/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod index 0a50fc3645daeb83d429228509346f025d45950d..427c1e2626f0baade4750445935fb8b335212bf9 100644 --- a/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod +++ b/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod @@ -8,7 +8,7 @@ <element>CampaignParticipant_entity</element> </siblings> <onValidation>%aditoprj%/entity/CampaignAddParticipants_entity/onValidation.js</onValidation> - <recordContainer>jdito</recordContainer> + <recordContainer>datalessConfig</recordContainer> <entityFields> <entityProvider> <name>#PROVIDER</name> @@ -18,7 +18,7 @@ <title>Campaign</title> <consumer>CampaignConsumer</consumer> <mandatory v="true" /> - <state>AUTO</state> + <state>EDITABLE</state> <valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaign_id/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaign_id/displayValueProcess.js</displayValueProcess> <onValueChange>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaign_id/onValueChange.js</onValueChange> @@ -40,7 +40,7 @@ </entityField> <entityField> <name>campaignParticipantMessage</name> - <state>READONLY</state> + <state>EDITABLE</state> <onValueChangeTypes> <element>PROCESS</element> </onValueChangeTypes> @@ -75,6 +75,7 @@ </entityConsumer> <entityField> <name>UID</name> + <state>EDITABLE</state> </entityField> <entityParameter> <name>currentCampaignId_param</name> @@ -102,15 +103,18 @@ <entityField> <name>campaignStepCurrentParticipantCount</name> <title>Current participants</title> + <state>EDITABLE</state> <displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstepcurrentparticipantcount/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>campaignStepMaxParticipantCount</name> <title>Max participants</title> + <state>EDITABLE</state> <displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstepmaxparticipantcount/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>isUpdate</name> + <state>EDITABLE</state> <valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/isupdate/valueProcess.js</valueProcess> </entityField> <entityParameter> @@ -123,8 +127,17 @@ </entityParameter> <entityField> <name>isOperationValid</name> + <state>EDITABLE</state> <valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js</valueProcess> </entityField> + <entityActionField> + <name>AddParticipants</name> + <title>Add Participants</title> + <onActionProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/addparticipants/onActionProcess.js</onActionProcess> + <iconId>NEON:GROUP_APPOINTMENT</iconId> + <state>DISABLED</state> + <stateProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/addparticipants/stateProcess.js</stateProcess> + </entityActionField> </entityFields> <recordContainers> <jDitoRecordContainer> @@ -138,5 +151,9 @@ </jDitoRecordFieldMapping> </recordFieldMappings> </jDitoRecordContainer> + <datalessRecordContainer> + <name>datalessConfig</name> + <alias>Data_alias</alias> + </datalessRecordContainer> </recordContainers> </entity> diff --git a/entity/CampaignAddParticipants_entity/entityfields/addparticipants/onActionProcess.js b/entity/CampaignAddParticipants_entity/entityfields/addparticipants/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..bbf377c5c3803bd9e8c294d1de8ce1ccca72e0d6 --- /dev/null +++ b/entity/CampaignAddParticipants_entity/entityfields/addparticipants/onActionProcess.js @@ -0,0 +1,153 @@ +import("system.neon"); +import("Sql_lib"); +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 = ""; +var conditionSourceTableName = vars.getString("$param.dataSourceTableName_param"); + +var campaignId = vars.getString("$field.CAMPAIGN_ID"); +var newCampaignStepId = vars.getString("$field.CAMPAIGNSTEP_ID"); +var isUpdate = vars.get("$field.isUpdate"); + +var colNamesCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnNames(); + +if(participantRowIds != null && participantRowIds.length > 0) +{ + let contactIdsToHandle = participantRowIds; + + if(isUpdate == "false") + contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByRowIds(campaignId, participantRowIds); + + _handleRowIds(contactIdsToHandle, campaignId); +} +else +{ + participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param")).condition; + _handleCondition(campaignId, conditionSourceTableName, participantCondition); +} + +if (!vars.exists("$param.currentCampaignId_param") || !vars.get("$param.currentCampaignId_param")) + neon.openContext("Campaign", "CampaignMain_view", [campaignId], neon.OPERATINGSTATE_VIEW, null); + +function _handleCondition(pCampaignId, pTargetTableName, pCondition) +{ + let contactIdsToHandle = []; + + let useRightJoinToGetOrgs = "false"; + if(pTargetTableName == "ORGANISATION") + { + useRightJoinToGetOrgs = "true"; + pCondition += " and PERSON.PERSONID is NULL" + } + + /* + * If it's an update of participants, get the participants defined by the condition in the selected campaign + * Because they already are participants, no restrictions apply to the affected IDs. + * + * Otherwise the participants ought to be inserted. The only restriction right now is, hat the participants to be inserted + * can't already be in this specific campaign. Therefore all IDs hat are defined by the condition and not in the campaign are selected. + */ + if(isUpdate == "true") + { + contactIdsToHandle = CampaignUtils.GetContactIdsInCampaignByCondition(pCampaignId, pCondition, useRightJoinToGetOrgs) + } + else + contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByCondition(pCampaignId, pCondition, useRightJoinToGetOrgs); + + _handleRowIds(contactIdsToHandle, pCampaignId); +} + +function _handleRowIds(pParticipantRowIds, pCampaignId) +{ + var oldStepIds = {}; + if(isUpdate == "true") + { + cols = [ "CAMPAIGNSTEP_ID", + "USER_EDIT", + "DATE_EDIT" + ]; + let oldSteps = newSelect("CAMPAIGNPARTICIPANTID, CAMPAIGNSTEP_ID") + .from("CAMPAIGNPARTICIPANT") + .whereIfSet("CAMPAIGNPARTICIPANT.CONTACT_ID", pParticipantRowIds, SqlBuilder.IN()) + .and("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", pCampaignId) + .table(true); + + oldSteps.forEach(function (step) + { + this[step[0]] = step[1]; + }, oldStepIds); + } + else + { + cols = [ "CAMPAIGNPARTICIPANTID" + ,"CONTACT_ID" + ,"CAMPAIGN_ID" + ,"CAMPAIGNSTEP_ID" + ,"USER_NEW" + ,"DATE_NEW" + ]; + } + + let statementArray = []; + let logArray = []; + + for (participant in pParticipantRowIds) + { + let campaignParticipantLogId = util.getNewUUID(); + + if(isUpdate == "true") + { + let oldCampaignStepId = oldStepIds[pParticipantRowIds[participant]] || ""; + let updatedValues = [newCampaignStepId, + vars.get("$sys.user"), + vars.get("$sys.date")]; + + let condition = newWhere("CAMPAIGNPARTICIPANT.CONTACT_ID", pParticipantRowIds[participant]) + .or("CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID", pParticipantRowIds[participant]); + + let valsCampaignParticipantLog = [ + pParticipantRowIds[participant], + campaignId, + newCampaignStepId, + campaignParticipantLogId, + vars.get("$sys.user"), + vars.get("$sys.date"), + oldCampaignStepId + ]; + + statementArray.push(["CAMPAIGNPARTICIPANT", cols, null, updatedValues, condition.build()]); + 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]); + } + } + if(isUpdate == "true") + { + db.updates(statementArray) + } + else + db.inserts(statementArray); + if(logArray.length > 0) + db.inserts(logArray); +} + diff --git a/entity/CampaignAddParticipants_entity/entityfields/addparticipants/stateProcess.js b/entity/CampaignAddParticipants_entity/entityfields/addparticipants/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..be5aec2ba0d4f21dc0a169a53489021c880b3c8b --- /dev/null +++ b/entity/CampaignAddParticipants_entity/entityfields/addparticipants/stateProcess.js @@ -0,0 +1,8 @@ +import("system.neon"); +import("system.result"); +import("system.vars"); + +if (vars.get("$sys.validationerrors")) + result.string(neon.COMPONENTSTATE_DISABLED); +else + result.string(neon.COMPONENTSTATE_EDITABLE); \ No newline at end of file diff --git a/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js b/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js index 44bfa0e717f9ed3d3ad50b2e759b2a558a61fef6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js +++ b/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js @@ -1,153 +0,0 @@ -import("system.neon"); -import("Sql_lib"); -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 = ""; -var conditionSourceTableName = vars.getString("$param.dataSourceTableName_param"); - -var campaignId = vars.getString("$field.CAMPAIGN_ID"); -var newCampaignStepId = vars.getString("$field.CAMPAIGNSTEP_ID"); -var isUpdate = vars.get("$field.isUpdate"); - -var colNamesCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnNames(); - -if(participantRowIds != null && participantRowIds.length > 0) -{ - let contactIdsToHandle = participantRowIds; - - if(isUpdate == "false") - contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByRowIds(campaignId, participantRowIds); - - _handleRowIds(contactIdsToHandle, campaignId); -} -else -{ - participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param")).condition; - _handleCondition(campaignId, conditionSourceTableName, participantCondition); -} - -if (!vars.exists("$param.currentCampaignId_param") || !vars.get("$param.currentCampaignId_param")) - neon.openContext("Campaign", "CampaignMain_view", [campaignId], neon.OPERATINGSTATE_VIEW, null); - -function _handleCondition(pCampaignId, pTargetTableName, pCondition) -{ - let contactIdsToHandle = []; - - let useRightJoinToGetOrgs = "false"; - if(pTargetTableName == "ORGANISATION") - { - useRightJoinToGetOrgs = "true"; - pCondition += " and PERSON.PERSONID is NULL" - } - - /* - * If it's an update of participants, get the participants defined by the condition in the selected campaign - * Because they already are participants, no restrictions apply to the affected IDs. - * - * Otherwise the participants ought to be inserted. The only restriction right now is, hat the participants to be inserted - * can't already be in this specific campaign. Therefore all IDs hat are defined by the condition and not in the campaign are selected. - */ - if(isUpdate == "true") - { - contactIdsToHandle = CampaignUtils.GetContactIdsInCampaignByCondition(pCampaignId, pCondition, useRightJoinToGetOrgs) - } - else - contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByCondition(pCampaignId, pCondition, useRightJoinToGetOrgs); - - _handleRowIds(contactIdsToHandle, pCampaignId); -} - -function _handleRowIds(pParticipantRowIds, pCampaignId) -{ - var oldStepIds = {}; - if(isUpdate == "true") - { - cols = [ "CAMPAIGNSTEP_ID", - "USER_EDIT", - "DATE_EDIT" - ]; - let oldSteps = newSelect("CAMPAIGNPARTICIPANTID, CAMPAIGNSTEP_ID") - .from("CAMPAIGNPARTICIPANT") - .whereIfSet("CAMPAIGNPARTICIPANT.CONTACT_ID", pParticipantRowIds, SqlBuilder.IN()) - .and("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", pCampaignId) - .table(true); - - oldSteps.forEach(function (step) - { - this[step[0]] = step[1]; - }, oldStepIds); - } - else - { - cols = [ "CAMPAIGNPARTICIPANTID" - ,"CONTACT_ID" - ,"CAMPAIGN_ID" - ,"CAMPAIGNSTEP_ID" - ,"USER_NEW" - ,"DATE_NEW" - ]; - } - - let statementArray = []; - let logArray = []; - - for (participant in pParticipantRowIds) - { - let campaignParticipantLogId = util.getNewUUID(); - - if(isUpdate == "true") - { - let oldCampaignStepId = oldStepIds[pParticipantRowIds[participant]] || ""; - let updatedValues = [newCampaignStepId, - vars.get("$sys.user"), - vars.get("$sys.date")]; - - let condition = newWhere("CAMPAIGNPARTICIPANT.CONTACT_ID", pParticipantRowIds[participant]) - .or("CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID", pParticipantRowIds[participant]); - - let valsCampaignParticipantLog = [ - pParticipantRowIds[participant], - campaignId, - newCampaignStepId, - campaignParticipantLogId, - vars.get("$sys.user"), - vars.get("$sys.date"), - oldCampaignStepId - ]; - - statementArray.push(["CAMPAIGNPARTICIPANT", cols, null, updatedValues, condition.build()]); - 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]); - } - } - if(isUpdate == "true") - { - db.updates(statementArray) - } - else - db.inserts(statementArray); - if(logArray.length > 0) - db.inserts(logArray); -} - diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod index 982458f2cdedc672389a377a7949594c224c85db..527cf895cbe9db6e2792cb90f6f33ec423f29b87 100644 --- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod +++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod @@ -6812,6 +6812,9 @@ <entry> <key>Add Recipients</key> </entry> + <entry> + <key>Add Participants</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> <sqlModels> diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index a0e0011a13cb369c1350778ac01900596f50711a..fb051c867e7261966840c95b518dc9af4771f9c2 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -8729,6 +8729,10 @@ Bitte Datumseingabe prüfen</value> <key>Add Recipients</key> <value>Empfänger hinzufügen</value> </entry> + <entry> + <key>Add Participants</key> + <value>Teilnehmer hinzufügen</value> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod index dec573717ba55c0eee1aadfb0d3f29ae8c3ef588..af79162fb2e409108cda9faec1cb926b7979a292 100644 --- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod +++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod @@ -6878,6 +6878,9 @@ <entry> <key>Add Recipients</key> </entry> + <entry> + <key>Add Participants</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/neonView/CampaignAddParticipantsEdit_view/CampaignAddParticipantsEdit_view.aod b/neonView/CampaignAddParticipantsEdit_view/CampaignAddParticipantsEdit_view.aod index 003bdaaffdf33969c6100a0952c0cd0d522a6473..51e47fdf6319fc525098bfd9ec85a8432ed0503a 100644 --- a/neonView/CampaignAddParticipantsEdit_view/CampaignAddParticipantsEdit_view.aod +++ b/neonView/CampaignAddParticipantsEdit_view/CampaignAddParticipantsEdit_view.aod @@ -3,7 +3,7 @@ <name>CampaignAddParticipantsEdit_view</name> <majorModelMode>DISTRIBUTED</majorModelMode> <size>SMALL</size> - <isOverlay v="true" /> + <isOverlay v="false" /> <overlayOrientation>PORTRAIT</overlayOrientation> <layout> <headerFooterLayout> @@ -46,5 +46,12 @@ <entityField>#ENTITY</entityField> <view>campaignParticipantMessage_view</view> </neonViewReference> + <actionsViewTemplate> + <name>ContinueActions</name> + <actions> + <element>AddParticipants</element> + </actions> + <entityField>#ENTITY</entityField> + </actionsViewTemplate> </children> </neonView> diff --git a/neonView/campaignParticipantMessage_view/campaignParticipantMessage_view.aod b/neonView/campaignParticipantMessage_view/campaignParticipantMessage_view.aod index fd667347c2afdca12346e7f189980fdf17c1f22e..f11aa26b7622597f92bbebfaa15af9b47767ff8e 100644 --- a/neonView/campaignParticipantMessage_view/campaignParticipantMessage_view.aod +++ b/neonView/campaignParticipantMessage_view/campaignParticipantMessage_view.aod @@ -11,6 +11,7 @@ <genericViewTemplate> <name>Message_view</name> <hideLabels v="true" /> + <hideEmptyFields v="true" /> <entityField>#ENTITY</entityField> <fields> <entityFieldLink> diff --git a/process/Campaign_lib/process.js b/process/Campaign_lib/process.js index 76a6c808995051fdfa248ab0177b7b3e8fb4a7bd..b38ab24f96c87d6895583dcb9f2b787ea503fd34 100644 --- a/process/Campaign_lib/process.js +++ b/process/Campaign_lib/process.js @@ -693,5 +693,5 @@ _CampaignUtils._openAddParticipantContext = function(pContext, pTargetDataExpres params["isUpdate_param"] = false; params["dataSourceTableName_param"] = pSourceTableName; - neon.openContext(pContext, null, null, neon.OPERATINGSTATE_NEW, params); + neon.openContext(pContext, "CampaignAddParticipantsEdit_view", null, neon.OPERATINGSTATE_VIEW, params); } \ No newline at end of file