From 67ebc2a8028f87f3fce4a3c2fa86bfd10fb5a20b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20V=C3=B6gl?= <a.voegl@adito.de> Date: Wed, 16 Dec 2020 13:17:18 +0000 Subject: [PATCH] [Projekt: Entwicklung - xRM][TicketNr.: 1068591][Kampagnenplanung - Bearbeiten - Verschieben von Stufen] --- .../jditorecordcontainer/contentProcess.js | 60 ++++++++++++------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/entity/CampaignPlanning_entity/recordcontainers/jditorecordcontainer/contentProcess.js b/entity/CampaignPlanning_entity/recordcontainers/jditorecordcontainer/contentProcess.js index 9f1541d2f9b..53985b5cc50 100644 --- a/entity/CampaignPlanning_entity/recordcontainers/jditorecordcontainer/contentProcess.js +++ b/entity/CampaignPlanning_entity/recordcontainers/jditorecordcontainer/contentProcess.js @@ -1,3 +1,4 @@ +import("system.logging"); import("JditoFilter_lib"); import("system.util"); import("system.db"); @@ -26,34 +27,47 @@ if (isMariaDB) columnName = "\`NAME\`"; } -var stepsRows = stepCondition.select("CAMPAIGNSTEPID, CAMPAIGNSTEP."+ columnName + ", CAMPAIGNSTEP.PREDECESSORSTEP_ID," +stepCondition.select("CAMPAIGNSTEPID, CAMPAIGNSTEP."+ columnName + ", CAMPAIGNSTEP.PREDECESSORSTEP_ID," + " CAMPAIGNSTEP.DESCRIPTION, CAMPAIGNSTEP.DATE_START, CAMPAIGNSTEP.DATE_END, CAMPAIGNID, CAMPAIGN."+ columnName +", CAMPAIGN.STATUS") .from("CAMPAIGN") - .join("CAMPAIGNSTEP", "CAMPAIGN.CAMPAIGNID = CAMPAIGNSTEP.CAMPAIGN_ID") - .orderBy("SORTING") - .table(); + .join("CAMPAIGNSTEP", "CAMPAIGN.CAMPAIGNID = CAMPAIGNSTEP.CAMPAIGN_ID"); + +if (vars.exists("$local.idvalues") && vars.get("$local.idvalues")) + stepCondition.and("CAMPAIGNSTEP.CAMPAIGNSTEPID", vars.get("$local.idvalues"), SqlBuilder.IN()); -stepsRows = stepsRows.map(function ([stepId, stepName, predecessorId, desc, stepStartDate, stepEndDate, campaignId, campaignName, campaignStatus]) +var stepsRows = stepCondition.orderBy("SORTING").table(); + +//this can happen when not a CampaignStep, but a Campaign node was selected +if(stepsRows.length == 0 && vars.get("$local.idvalues") && newSelect("count(*)").from("CAMPAIGN").where("CAMPAIGN.CAMPAIGNID", vars.get("$local.idvalues")).cell() > 0) { - if (!campaignRows[campaignId]) - { - let startDate = CampaignUtils.getCampaignStartDate(campaignId); - let endDate = CampaignUtils.getCampaignEndDate(campaignId); - campaignRows[campaignId] = [campaignId, campaignName, null, null, startDate, endDate, campaignId, TARGET_CONTEXT_ROOT_ELEMENT, campaignStatus]; - } - stepIds[stepId] = true; - - return [stepId, stepName, predecessorId || campaignId, desc, stepStartDate, stepEndDate, campaignId, TARGET_CONTEXT_ELEMENT, campaignStatus]; -}); + stepsRows = [[vars.get("$local.idvalues"), "", "", "", "", "", vars.get("$local.idvalues"), "", ""]] +} -//replace all predecessor ids that are not in the tree with the campaign id -stepsRows.forEach(function (row) +if(!vars.get("$local.idvalues")) { - if (!(stepIds[row[2]])) - row[2] = row[6]; -}); + stepsRows = stepsRows.map(function ([stepId, stepName, predecessorId, desc, stepStartDate, stepEndDate, campaignId, campaignName, campaignStatus]) + { + if (!campaignRows[campaignId]) + { + let startDate = CampaignUtils.getCampaignStartDate(campaignId); + let endDate = CampaignUtils.getCampaignEndDate(campaignId); + campaignRows[campaignId] = [campaignId, campaignName, null, null, startDate, endDate, campaignId, TARGET_CONTEXT_ROOT_ELEMENT, campaignStatus]; + } + stepIds[stepId] = true; + + return [stepId, stepName, predecessorId || campaignId, desc, stepStartDate, stepEndDate, campaignId, TARGET_CONTEXT_ELEMENT, campaignStatus]; + }); -//convert the object to an array -campaignRows = Object.keys(campaignRows).map(function (id) {return campaignRows[id];}); + //replace all predecessor ids that are not in the tree with the campaign id + stepsRows.forEach(function (row) + { + if (!(stepIds[row[2]])) + row[2] = row[6]; + }); -result.object(campaignRows.concat(stepsRows)) + //convert the object to an array + campaignRows = Object.keys(campaignRows).map(function (id) {return campaignRows[id];}); + + stepsRows = campaignRows.concat(stepsRows); +} +result.object(stepsRows); -- GitLab