Skip to content
Snippets Groups Projects
Commit 9e21a6c4 authored by S.Listl's avatar S.Listl
Browse files

CampaignAddParticipants message improved

parent 292ca724
No related branches found
No related tags found
No related merge requests found
......@@ -96,23 +96,27 @@ if(selectedCampaignId != '')
{
messageString = translate.text("All selected participants already are in the campaign");
}
else if(hasStepEnoughSlots(countValidParticipantsToAdd))
{
messageString = translate.withArguments("%0/%1 participant(s) will be added to the selected campaign step", [countValidParticipantsToAdd, countParticipantsToAdd]);
resultValue = "true";
}
else
{
messageString = translate.withArguments("Not enough slots for %0/%1 participant(s)", [countValidParticipantsToAdd, countParticipantsToAdd]);
let excess = getParticipantExcess(countValidParticipantsToAdd);
if (excess > 0)
{
messageString = translate.withArguments("Not enough slots for %0/%1 participant(s)", [excess, countParticipantsToAdd]);
}
else
{
messageString = translate.withArguments("%0/%1 participant(s) will be added to the selected campaign step", [countValidParticipantsToAdd, countParticipantsToAdd]);
resultValue = "true";
}
}
neon.setFieldValue("$field.campaignParticipantMessage", messageString);
result.string(resultValue);
}
function hasStepEnoughSlots(pCountToAdd)
function getParticipantExcess (pCountToAdd)
{
let currentParticipants = CampaignUtils.getParticipantCountForStep(selectedCampaignStepId)
let maxParticipants = CampaignUtils.getMaxParticipantCountForStep(selectedCampaignStepId)
return (parseInt(currentParticipants) + parseInt(pCountToAdd)) <= maxParticipants;
return (parseInt(currentParticipants) + parseInt(pCountToAdd)) - maxParticipants;
}
\ 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