Commit 894abd73 by GD-A-150752

Bug-Fix S52544051 # Sprint 1 Issues #Getting error when removing stages

parent 41311a2b
......@@ -183,17 +183,18 @@
<p-panel [toggleable]="true" #panel [collapsed]="true" toggler="header">
<p-header>
<span (click)="toggleInput($event, 'StageName'+stage.SortOrder, true)"
*ngIf="showLabel('StageName'+stage.SortOrder)"
<span (click)="toggleInput($event, 'StageName'+stage.ObjectID, true)"
*ngIf="showLabel('StageName'+stage.ObjectID)"
id="StageName{{stage.ObjectID}}"
class="ui-panel-title">
{{getStageHeader(stage)}}
</span>
<input (blur)="toggleInput($event, 'StageName'+stage.SortOrder, false)"
*ngIf="!showLabel('StageName'+stage.SortOrder)"
<input (blur)="toggleInput($event, 'StageName'+stage.ObjectID, false)"
*ngIf="!showLabel('StageName'+stage.ObjectID)"
[(ngModel)]="stage.Name" [disabled]="showLoader"
class="form-control panel-header-input"
id="StageName{{stage.SortOrder}}Id"
name="StageName{{stage.SortOrder}}"
id="StageName{{stage.ObjectID}}Id"
name="StageName{{stage.ObjectID}}"
pInputText required/>
</p-header>
<div class="ui-g form-group" *ngIf="!panel.collapsed">
......
......@@ -278,7 +278,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
* number of days, hours and minutes.
* Input mask gets values in the form of __:__:__
* Parsing of this value takes place in this function, moreover it sorts the messages as well
* @param message
* @WorkflowMessageModel message
*/
generateDelayString(message: WorkflowMessageModel): void {
......@@ -351,8 +351,8 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
/**
* This function sets the parameters to be sent to edit-message-template component
* @param $event
* @param message
* @param $event Browser Event
* @param message WorkflowMessageModel
*/
showMessageTemplateDialog($event, message: WorkflowMessageModel): void {
const template = $event.value;
......@@ -378,7 +378,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
/**
* When the dialog is closed, whether a template is created or updated, it is fetched by sending request to API.
* Newly created or updated template is selected and shown in the dropdown of message in message scheduling section.
* @param value
* @param value number
*/
closeDialog(value): void {
if (value === -1) {
......@@ -417,6 +417,14 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.removeStepType(selectedStepType);
}
stepRemovalProcess(step: WorkflowStepModel, stage: WorkflowStageModel): void {
const stepType = step.StepType;
this.utilsService.removeMultiRefObject(step, stage, 'Steps', this.createdObjs, this.updatedObjs, this.deletedObjs);
stage.Steps.map((stageStep, index) => stageStep.SortOrder = index + 1);
this.addStepType(stepType);
}
removeStep(step: WorkflowStepModel, stage: WorkflowStageModel): void {
this.confirmationService.confirm({
message: 'Are you sure you want to delete this record?',
......@@ -424,11 +432,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
icon: 'fa fa-trash',
key: 'RemoveRow',
accept: () => {
const stepType = step.StepType;
this.utilsService.removeMultiRefObject(step, stage, 'Steps', this.createdObjs, this.updatedObjs, this.deletedObjs);
stage.Steps.map((step, index) => step.SortOrder = index + 1);
this.addStepType(stepType);
this.stepRemovalProcess(step, stage);
}
});
}
......@@ -473,6 +477,15 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.reOrderStages();
}
/**
* Removal of stage is done in three steps
* removal of its Workflow messages
* removal of its Steps and adding steps back to original stepsEnum array
* removal of stage itself
* Using for loop instead of forEach to restrict the number of iterations
* Keeping the index 0 in order to make sure always first item is being deleted.
* @param stage WorkflowStageModel
*/
removeStage(stage: WorkflowStageModel): void {
this.confirmationService.confirm({
message: 'Are you sure you want to delete this record?',
......@@ -480,6 +493,18 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
icon: 'fa fa-trash',
key: 'RemoveRow',
accept: () => {
// Removing messages of stage
stage.WorkFlowMessages.forEach(message => {
this.utilsService.removeMultiRefObject(message, stage, 'WorkFlowMessages', this.createdObjs,
this.updatedObjs, this.deletedObjs);
});
// Adding steps in dropdown followed by removing Steps of stage
const stepsLength = stage.Steps.length;
for (let i = 0; i < stepsLength; i++) {
this.stepRemovalProcess(stage.Steps[0], stage);
}
this.utilsService.removeMultiRefObject(stage, this.workflow, 'WorkFlowStages', this.createdObjs,
this.updatedObjs, this.deletedObjs);
this.workflow.WorkFlowStages.forEach((stag, index) => stag.SortOrder = index + 1);
......@@ -509,7 +534,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.utilsService.clearErrorMessages();
const assoc = [ASSOCS.WORKFLOW_STAGE, [ASSOCS.WORKFLOW_STAGE, ASSOCS.WORKFLOW_MESSAGE, ASSOCS.MESSAGE_TEMPLATE].join('.'),
[ASSOCS.WORKFLOW_STAGE, ASSOCS.WORKFLOW_MESSAGE].join('.'), [ASSOCS.WORKFLOW_STAGE, ASSOCS.WORKFLOW_STEP].join('.')];
[ASSOCS.WORKFLOW_STAGE, ASSOCS.WORKFLOW_MESSAGE].join('.'), [ASSOCS.WORKFLOW_STAGE, ASSOCS.WORKFLOW_STEP].join('.')];
this.subscriptions.push(this.editWorkflowTemplateService.getWorkflowTemplateByID(id, assoc)
.subscribe(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment