Commit 894abd73 by GD-A-150752

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

parent 41311a2b
...@@ -183,17 +183,18 @@ ...@@ -183,17 +183,18 @@
<p-panel [toggleable]="true" #panel [collapsed]="true" toggler="header"> <p-panel [toggleable]="true" #panel [collapsed]="true" toggler="header">
<p-header> <p-header>
<span (click)="toggleInput($event, 'StageName'+stage.SortOrder, true)" <span (click)="toggleInput($event, 'StageName'+stage.ObjectID, true)"
*ngIf="showLabel('StageName'+stage.SortOrder)" *ngIf="showLabel('StageName'+stage.ObjectID)"
id="StageName{{stage.ObjectID}}"
class="ui-panel-title"> class="ui-panel-title">
{{getStageHeader(stage)}} {{getStageHeader(stage)}}
</span> </span>
<input (blur)="toggleInput($event, 'StageName'+stage.SortOrder, false)" <input (blur)="toggleInput($event, 'StageName'+stage.ObjectID, false)"
*ngIf="!showLabel('StageName'+stage.SortOrder)" *ngIf="!showLabel('StageName'+stage.ObjectID)"
[(ngModel)]="stage.Name" [disabled]="showLoader" [(ngModel)]="stage.Name" [disabled]="showLoader"
class="form-control panel-header-input" class="form-control panel-header-input"
id="StageName{{stage.SortOrder}}Id" id="StageName{{stage.ObjectID}}Id"
name="StageName{{stage.SortOrder}}" name="StageName{{stage.ObjectID}}"
pInputText required/> pInputText required/>
</p-header> </p-header>
<div class="ui-g form-group" *ngIf="!panel.collapsed"> <div class="ui-g form-group" *ngIf="!panel.collapsed">
......
...@@ -278,7 +278,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -278,7 +278,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
* number of days, hours and minutes. * number of days, hours and minutes.
* Input mask gets values in the form of __:__:__ * Input mask gets values in the form of __:__:__
* Parsing of this value takes place in this function, moreover it sorts the messages as well * Parsing of this value takes place in this function, moreover it sorts the messages as well
* @param message * @WorkflowMessageModel message
*/ */
generateDelayString(message: WorkflowMessageModel): void { generateDelayString(message: WorkflowMessageModel): void {
...@@ -351,8 +351,8 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -351,8 +351,8 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
/** /**
* This function sets the parameters to be sent to edit-message-template component * This function sets the parameters to be sent to edit-message-template component
* @param $event * @param $event Browser Event
* @param message * @param message WorkflowMessageModel
*/ */
showMessageTemplateDialog($event, message: WorkflowMessageModel): void { showMessageTemplateDialog($event, message: WorkflowMessageModel): void {
const template = $event.value; const template = $event.value;
...@@ -378,7 +378,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -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. * 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. * 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 { closeDialog(value): void {
if (value === -1) { if (value === -1) {
...@@ -417,6 +417,14 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -417,6 +417,14 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.removeStepType(selectedStepType); 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 { removeStep(step: WorkflowStepModel, stage: WorkflowStageModel): void {
this.confirmationService.confirm({ this.confirmationService.confirm({
message: 'Are you sure you want to delete this record?', message: 'Are you sure you want to delete this record?',
...@@ -424,11 +432,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -424,11 +432,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
icon: 'fa fa-trash', icon: 'fa fa-trash',
key: 'RemoveRow', key: 'RemoveRow',
accept: () => { accept: () => {
const stepType = step.StepType; this.stepRemovalProcess(step, stage);
this.utilsService.removeMultiRefObject(step, stage, 'Steps', this.createdObjs, this.updatedObjs, this.deletedObjs);
stage.Steps.map((step, index) => step.SortOrder = index + 1);
this.addStepType(stepType);
} }
}); });
} }
...@@ -473,6 +477,15 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -473,6 +477,15 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.reOrderStages(); 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 { removeStage(stage: WorkflowStageModel): void {
this.confirmationService.confirm({ this.confirmationService.confirm({
message: 'Are you sure you want to delete this record?', message: 'Are you sure you want to delete this record?',
...@@ -480,6 +493,18 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -480,6 +493,18 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
icon: 'fa fa-trash', icon: 'fa fa-trash',
key: 'RemoveRow', key: 'RemoveRow',
accept: () => { 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.utilsService.removeMultiRefObject(stage, this.workflow, 'WorkFlowStages', this.createdObjs,
this.updatedObjs, this.deletedObjs); this.updatedObjs, this.deletedObjs);
this.workflow.WorkFlowStages.forEach((stag, index) => stag.SortOrder = index + 1); this.workflow.WorkFlowStages.forEach((stag, index) => stag.SortOrder = index + 1);
...@@ -509,7 +534,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -509,7 +534,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.utilsService.clearErrorMessages(); this.utilsService.clearErrorMessages();
const assoc = [ASSOCS.WORKFLOW_STAGE, [ASSOCS.WORKFLOW_STAGE, ASSOCS.WORKFLOW_MESSAGE, ASSOCS.MESSAGE_TEMPLATE].join('.'), 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) this.subscriptions.push(this.editWorkflowTemplateService.getWorkflowTemplateByID(id, assoc)
.subscribe( .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