diff --git a/entity/CampaignStep_entity/CampaignStep_entity.aod b/entity/CampaignStep_entity/CampaignStep_entity.aod index c090c20d4ce316c83921200df4a54073f2135724..98f8c9ab6be8c4a0fb9717db8b329df74f40a675 100644 --- a/entity/CampaignStep_entity/CampaignStep_entity.aod +++ b/entity/CampaignStep_entity/CampaignStep_entity.aod @@ -379,10 +379,29 @@ </entityParameter> </children> </entityConsumer> + <entityActionGroup> + <name>group</name> + <children> + <entityActionField> + <name>moveUp</name> + <onActionProcess>%aditoprj%/entity/CampaignStep_entity/entityfields/group/children/moveup/onActionProcess.js</onActionProcess> + <iconId>VAADIN:ARROW_UP</iconId> + <state>DISABLED</state> + <stateProcess>%aditoprj%/entity/CampaignStep_entity/entityfields/group/children/moveup/stateProcess.js</stateProcess> + </entityActionField> + <entityActionField> + <name>moveDown</name> + <onActionProcess>%aditoprj%/entity/CampaignStep_entity/entityfields/group/children/movedown/onActionProcess.js</onActionProcess> + <iconId>VAADIN:ARROW_DOWN</iconId> + <stateProcess>%aditoprj%/entity/CampaignStep_entity/entityfields/group/children/movedown/stateProcess.js</stateProcess> + </entityActionField> + </children> + </entityActionGroup> </entityFields> <recordContainers> <dbRecordContainer> <name>db</name> + <hasDependentRecords v="true" /> <conditionProcess>%aditoprj%/entity/CampaignStep_entity/recordcontainers/db/conditionProcess.js</conditionProcess> <orderClauseProcess>%aditoprj%/entity/CampaignStep_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess> <onDBInsert>%aditoprj%/entity/CampaignStep_entity/recordcontainers/db/onDBInsert.js</onDBInsert> diff --git a/entity/CampaignStep_entity/entityfields/group/children/movedown/onActionProcess.js b/entity/CampaignStep_entity/entityfields/group/children/movedown/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..d55de329e829bb8bfc0289f86bd0b788690775df --- /dev/null +++ b/entity/CampaignStep_entity/entityfields/group/children/movedown/onActionProcess.js @@ -0,0 +1,9 @@ +import("system.vars"); +import("system.neon"); +import("Campaign_lib"); + +CampaignUtils.moveStepDown(vars.get("$field.CAMPAIGNSTEPID")) + +neon.refreshAll(); + + diff --git a/entity/CampaignStep_entity/entityfields/group/children/movedown/stateProcess.js b/entity/CampaignStep_entity/entityfields/group/children/movedown/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..984483b8fc661196e26875d32d1ea126410d084d --- /dev/null +++ b/entity/CampaignStep_entity/entityfields/group/children/movedown/stateProcess.js @@ -0,0 +1,27 @@ +import("system.result"); +import("Sql_lib"); +import("system.vars"); +import("system.neon"); + +var sorting = parseInt(vars.get("$field.SORTING")); +var campaignId = vars.get("$field.CAMPAIGN_ID"); +var campaignStepId = vars.get("$field.CAMPAIGNSTEPID"); + +var validNextStep = newSelect("CAMPAIGNSTEP.CAMPAIGNSTEPID") + .from("CAMPAIGNSTEP") + .where("CAMPAIGNSTEP.CAMPAIGN_ID",campaignId) + .and("CAMPAIGNSTEP.SORTING",sorting+1) + .and(newWhere("CAMPAIGNSTEP.PREDECESSORSTEP_ID",campaignStepId,SqlBuilder.NOT_EQUAL()) + .or("CAMPAIGNSTEP.PREDECESSORSTEP_ID is null")) + .cell(); + + +if (validNextStep) +{ + result.string(neon.COMPONENTSTATE_EDITABLE); +} +else +{ + result.string(neon.COMPONENTSTATE_DISABLED); +} + diff --git a/entity/CampaignStep_entity/entityfields/group/children/moveup/onActionProcess.js b/entity/CampaignStep_entity/entityfields/group/children/moveup/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..f6c210312a2f9fb04333581c8610b8ffa7b9cb88 --- /dev/null +++ b/entity/CampaignStep_entity/entityfields/group/children/moveup/onActionProcess.js @@ -0,0 +1,8 @@ +import("system.vars"); +import("system.neon"); +import("Campaign_lib"); + +CampaignUtils.moveStepUp(vars.get("$field.CAMPAIGNSTEPID")) + + +neon.refreshAll(); diff --git a/entity/CampaignStep_entity/entityfields/group/children/moveup/stateProcess.js b/entity/CampaignStep_entity/entityfields/group/children/moveup/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..f24f17d1e3f1e4cbc209549fc52a408789a746bb --- /dev/null +++ b/entity/CampaignStep_entity/entityfields/group/children/moveup/stateProcess.js @@ -0,0 +1,25 @@ +import("system.result"); +import("Sql_lib"); +import("system.vars"); +import("system.neon"); + +var sorting = parseInt(vars.get("$field.SORTING")); +var campaignId = vars.get("$field.CAMPAIGN_ID"); +var predecessorStepId = vars.get("$field.PREDECESSORSTEP_ID"); + +var validPreviousStep = newSelect("CAMPAIGNSTEP.CAMPAIGNSTEPID") + .from("CAMPAIGNSTEP") + .where("CAMPAIGNSTEP.CAMPAIGN_ID",campaignId) + .and("CAMPAIGNSTEP.SORTING",sorting-1) + .and("CAMPAIGNSTEP.CAMPAIGNSTEPID",predecessorStepId,SqlBuilder.NOT_EQUAL()) + .cell(); + +if (validPreviousStep) +{ + result.string(neon.COMPONENTSTATE_EDITABLE); +} +else +{ + result.string(neon.COMPONENTSTATE_DISABLED); +} + diff --git a/entity/CampaignStep_entity/recordcontainers/db/onDBDelete.js b/entity/CampaignStep_entity/recordcontainers/db/onDBDelete.js index 6ff91a5eb319120b527776868367d3cdb0f445f1..c851ee9b66d5efaa3ee2e62cdfff1beb6e4402e2 100644 --- a/entity/CampaignStep_entity/recordcontainers/db/onDBDelete.js +++ b/entity/CampaignStep_entity/recordcontainers/db/onDBDelete.js @@ -1,3 +1,21 @@ +import("system.neon"); +import("system.vars"); import("Workflow_lib"); +import("Sql_lib"); +import("Campaign_lib"); + +newSelect("CAMPAIGNSTEP.CAMPAIGNSTEPID") +.from("CAMPAIGNSTEP") +.where("CAMPAIGNSTEP.CAMPAIGN_ID",vars.get("$field.CAMPAIGN_ID")) +.and("CAMPAIGNSTEP.SORTING",vars.get("$field.SORTING"),SqlBuilder.GREATER_OR_EQUAL()) +.orderBy("CAMPAIGNSTEP.SORTING asc") +.arrayColumn() +.forEach(function(pCampaignStepId) + { + CampaignUtils.moveStepUp(pCampaignStepId) + }); + +newWhere("CAMPAIGNSTEP.PREDECESSORSTEP_ID",vars.get("$field.CAMPAIGNSTEPID")) +.updateFields({"CAMPAIGNSTEP.PREDECESSORSTEP_ID":null}); WorkflowSignalSender.deleted(); \ No newline at end of file diff --git a/neonView/CampaignStepFilter_view/CampaignStepFilter_view.aod b/neonView/CampaignStepFilter_view/CampaignStepFilter_view.aod index 84f150264f430b4cac557a8e95af70fb5c04cacf..6f7b3669c89ad85f11a5129cb3be62cfe35d9a1c 100644 --- a/neonView/CampaignStepFilter_view/CampaignStepFilter_view.aod +++ b/neonView/CampaignStepFilter_view/CampaignStepFilter_view.aod @@ -15,6 +15,7 @@ <name>StepsTable</name> <autoNewRow v="false" /> <entityField>#ENTITY</entityField> + <favoriteActionGroup1>group</favoriteActionGroup1> <isEditable v="true" /> <columns> <neonTableColumn> @@ -62,6 +63,7 @@ <treeTableViewTemplate> <name>Treetable</name> <entityField>#ENTITY</entityField> + <favoriteActionGroup1>group</favoriteActionGroup1> <columns> <neonTreeTableColumn> <name>2246fe5a-d4ed-454a-9007-6c1716ad2a1e</name> diff --git a/process/Campaign_lib/process.js b/process/Campaign_lib/process.js index f488f0ee653f84eb47ab793219f9965bfd6d6a04..808c85d412e2b8ed1c67f82693493b11d95cbc1b 100644 --- a/process/Campaign_lib/process.js +++ b/process/Campaign_lib/process.js @@ -814,4 +814,54 @@ CampaignUtils.getResolvedCampaignStepSqlpPart = function(pCampaignId){ var res = SqlUtils.getResolvingCaseWhen(campaignSteps, "CAMPAIGNSTEP.CAMPAIGNSTEPID"); return SqlUtils.translateStatementWithQuotes(res); +} + +/* + * Swaps the Sorting of a campaignstep with the one above it + * + * @param {String} pCampaignStepId CampaignStepId of the step that should be moved up + */ +CampaignUtils.moveStepUp = function(pCampaignStepId){ + var sorting; + var campaignId; + + [campaignId,sorting] = newSelect(["CAMPAIGNSTEP.CAMPAIGN_ID","CAMPAIGNSTEP.SORTING"]) + .from("CAMPAIGNSTEP") + .where("CAMPAIGNSTEP.CAMPAIGNSTEPID",pCampaignStepId) + .arrayRow(); + + sorting = parseInt(sorting); + + + newWhere("CAMPAIGNSTEP.CAMPAIGN_ID",campaignId) + .and("CAMPAIGNSTEP.SORTING",sorting-1) + .updateFields({"SORTING":sorting}); + + newWhere("CAMPAIGNSTEP.CAMPAIGNSTEPID",pCampaignStepId) + .updateFields({"SORTING":sorting-1}); +} + +/* + * Swaps the Sorting of a campaignstep with the one below it + * + * @param {String} pCampaignStepId CampaignStepId of the step that should be moved down + */ +CampaignUtils.moveStepDown = function(pCampaignStepId){ + var sorting; + var campaignId; + + [campaignId,sorting] = newSelect(["CAMPAIGNSTEP.CAMPAIGN_ID","CAMPAIGNSTEP.SORTING"]) + .from("CAMPAIGNSTEP") + .where("CAMPAIGNSTEP.CAMPAIGNSTEPID",pCampaignStepId) + .arrayRow(); + + sorting = parseInt(sorting); + + + newWhere("CAMPAIGNSTEP.CAMPAIGN_ID",campaignId) + .and("CAMPAIGNSTEP.SORTING",sorting+1) + .updateFields({"SORTING":sorting}); + + newWhere("CAMPAIGNSTEP.CAMPAIGNSTEPID",pCampaignStepId) + .updateFields({"SORTING":sorting+1}); } \ No newline at end of file