From fbc9481fbc575c9fb228090bfe3ef29f7a6e5463 Mon Sep 17 00:00:00 2001 From: "d.buechler" <d.buechler@adito.de> Date: Tue, 30 Apr 2019 10:17:50 +0200 Subject: [PATCH] If the max participants value is changed it now gets validated against the current participants. It is required to be maxParticipants >= currentParticipants --- .../entityfields/campaign_id/stateProcess.js | 17 +++++++++-------- .../CampaignStep_entity/CampaignStep_entity.aod | 1 + .../maxparticipants/onValidation.js | 10 ++++++++++ .../_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod | 3 +++ language/_____LANGUAGE_de/_____LANGUAGE_de.aod | 4 ++++ language/_____LANGUAGE_en/_____LANGUAGE_en.aod | 3 +++ process/Campaign_lib/process.js | 10 ++++++++++ 7 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 entity/CampaignStep_entity/entityfields/maxparticipants/onValidation.js diff --git a/entity/CampaignParticipant_entity/entityfields/campaign_id/stateProcess.js b/entity/CampaignParticipant_entity/entityfields/campaign_id/stateProcess.js index b9a78038b4..ca54a5bcb3 100644 --- a/entity/CampaignParticipant_entity/entityfields/campaign_id/stateProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/campaign_id/stateProcess.js @@ -1,8 +1,9 @@ -import("system.neon"); -import("system.result"); -import("system.vars"); - -if(vars.exists("$param.CampaignId_param") && vars.get("$param.CampaignId_param") != null) - result.string(neon.COMPONENTSTATE_READONLY); -else - result.string(neon.COMPONENTSTATE_EDITABLE); \ No newline at end of file +//import("system.neon"); +//import("system.result"); +//import("system.vars"); +// +//if(vars.exists("$param.CampaignId_param") && vars.get("$param.CampaignId_param") != null) +// result.string(neon.COMPONENTSTATE_READONLY); +//else +// result.string(neon.COMPONENTSTATE_EDITABLE); +//todo campaignllokup readonly? \ No newline at end of file diff --git a/entity/CampaignStep_entity/CampaignStep_entity.aod b/entity/CampaignStep_entity/CampaignStep_entity.aod index 1ad56f5df2..2d3064f2ee 100644 --- a/entity/CampaignStep_entity/CampaignStep_entity.aod +++ b/entity/CampaignStep_entity/CampaignStep_entity.aod @@ -162,6 +162,7 @@ <title>Max participants</title> <contentType>NUMBER</contentType> <mandatory v="true" /> + <onValidation>%aditoprj%/entity/CampaignStep_entity/entityfields/maxparticipants/onValidation.js</onValidation> </entityField> <entityConsumer> <name>CampaignParticipantsConsumer</name> diff --git a/entity/CampaignStep_entity/entityfields/maxparticipants/onValidation.js b/entity/CampaignStep_entity/entityfields/maxparticipants/onValidation.js new file mode 100644 index 0000000000..378e2a7a10 --- /dev/null +++ b/entity/CampaignStep_entity/entityfields/maxparticipants/onValidation.js @@ -0,0 +1,10 @@ +import("Campaign_lib"); +import("system.result"); +import("Entity_lib"); +import("system.vars"); + +var currentParticipantsCount = parseInt(vars.get("$field.CurrentMaxParticipantsInfo")[0]); +var newMaxParticipantsCount = parseInt(ProcessHandlingUtils.getOnValidationValue(vars.get("$field.MAXPARTICIPANTS"))); + +if(newMaxParticipantsCount < currentParticipantsCount) + result.string(CampaignUtils.getMaxParticipantsValidationMessage()); \ No newline at end of file diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod index 7d36afb0e9..4f65c33c3a 100644 --- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod +++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod @@ -3087,6 +3087,9 @@ <entry> <key>per</key> </entry> + <entry> + <key>The max participants count has to be equal or greater than the count of the current 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 7ea7f13841..e83bb5a1df 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -3939,6 +3939,10 @@ <key>per</key> <value>pro</value> </entry> + <entry> + <key>The max participants count has to be equal or greater than the count of the current participants!</key> + <value>Die maximale Teilnehmerzahl muss gleich oder größer der aktuellen Teilnehmerzahl sein!</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 dc64f28a58..b03d58b9b3 100644 --- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod +++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod @@ -3121,6 +3121,9 @@ <entry> <key>per</key> </entry> + <entry> + <key>The max participants count has to be equal or greater than the count of the current participants!</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/process/Campaign_lib/process.js b/process/Campaign_lib/process.js index d4932b0cc7..04d51f880c 100644 --- a/process/Campaign_lib/process.js +++ b/process/Campaign_lib/process.js @@ -1,3 +1,4 @@ +import("system.translate"); import("system.logging"); import("system.vars"); import("system.db"); @@ -195,6 +196,15 @@ CampaignUtils.getCampaignEndDate = function(pCapmaignId) return db.cell(campaignIdCondition.buildSql("SELECT DATE_END, SORTING FROM CAMPAIGNSTEP", "1=2", "order by SORTING ASC FETCH FIRST 1 ROWS ONLY")); } +/** + * todo + */ +CampaignUtils.getMaxParticipantsValidationMessage = function() +{ + //todo how/where should this text be stored? + return translate.text("The max participants count has to be equal or greater than the count of the current participants!"); +} + /** * Methods for campaignmanagement. * Do not create an instance of this! -- GitLab