We are using the Bryntum TaskBoard editor modal to allow users to edit tasks. When the user clicks the "Save" button:
We intercept the save action using the beforeSave event to make an API call and validate the changes.
If the API call fails (e.g., due to a server error or invalid data), we want to:
Keep the editor modal open.
Prevent the changes from being saved.
Display an error message to the user.
How can we prevent the editor modal from closing when the API call during the beforeSave event fails? Currently, even if the API returns an error, the modal closes, and the changes are saved locally. We need a way to ensure that the modal stays open, and the user can retry saving after fixing the issue.
ngAfterViewInit(): void {
this.taskboard.on('beforeSave', ({ source, editor, record, values }) => {
this.updateTaskRecordService(values);
}
}
private updateTaskRecordService(taskData: any){
this.tasksService.updateTask(taskData).subscribe({
next: (response: any) => {
// modal hide
this.toastService.success(response.message);
},
error: (error: any) => {
// error
// modal not hide
},
});
}