Skip to content
Snippets Groups Projects
Commit ccf8ab8e authored by Martin Groppe's avatar Martin Groppe Committed by Sebastian Listl
Browse files

M 1074934 campaignstep sorting changeable

parent e8ddd313
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
import("system.vars");
import("system.neon");
import("Campaign_lib");
CampaignUtils.moveStepDown(vars.get("$field.CAMPAIGNSTEPID"))
neon.refreshAll();
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);
}
import("system.vars");
import("system.neon");
import("Campaign_lib");
CampaignUtils.moveStepUp(vars.get("$field.CAMPAIGNSTEPID"))
neon.refreshAll();
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);
}
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
......@@ -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>
......
......@@ -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
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