Skip to content

Commit

Permalink
[DURACOM-206] fixed bug that processes without required params was sa…
Browse files Browse the repository at this point in the history
…ving after cancel button click
  • Loading branch information
aliaksei.bykau committed Dec 13, 2023
1 parent 8ba14aa commit ae02099
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/process-page/form/process-form.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1 class="col-12">
<ds-scripts-select [script]="selectedScript" (select)="selectedScript = $event; parameters = undefined"></ds-scripts-select>
<ds-process-parameters [initialParams]="parameters" [script]="selectedScript" (updateParameters)="parameters = $event"></ds-process-parameters>
<a [routerLink]="['/processes']" class="btn btn-danger float-left">{{ 'process.new.cancel' | translate }}</a>
<button type="submit" class="btn btn-primary float-right">{{ 'process.new.submit' | translate }}</button>
<button type="submit" (click)="cancelAction()" class="btn btn-primary float-right">{{ 'process.new.submit' | translate }}</button>
</form>
</div>
<div class="col-12 col-md-6">
Expand Down
11 changes: 10 additions & 1 deletion src/app/process-page/form/process-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export class ProcessFormComponent implements OnInit {
*/
public missingParameters = [];

/**
* Boolean value to use to cancel the process
*/
private isFormCanceled = false;

constructor(
private scriptService: ScriptDataService,
private notificationsService: NotificationsService,
Expand All @@ -73,7 +78,7 @@ export class ProcessFormComponent implements OnInit {
if (isEmpty(this.parameters)) {
this.parameters = [];
}
if (!this.validateForm(form) || this.isRequiredMissing()) {
if (!this.validateForm(form) || this.isRequiredMissing() || this.isFormCanceled) {
return;
}

Expand Down Expand Up @@ -149,6 +154,10 @@ export class ProcessFormComponent implements OnInit {
will fix this when the removeByHrefSubstring changes are merged */
this.router.navigateByUrl(getProcessListRoute());
}

public cancelAction() {
this.isFormCanceled = true;

Check warning on line 159 in src/app/process-page/form/process-form.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/process-page/form/process-form.component.ts#L159

Added line #L159 was not covered by tests
}
}

export function controlContainerFactory(controlContainer?: ControlContainer) {
Expand Down

0 comments on commit ae02099

Please sign in to comment.