Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bug that processes without required params was saving after cancel button click #61

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
*/
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 @@
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 @@
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