diff --git a/src-ui/src/app/components/manage/ocr-templates/ocr-templates.component.ts b/src-ui/src/app/components/manage/ocr-templates/ocr-templates.component.ts index a270b7c6a..a1c4b9bd4 100644 --- a/src-ui/src/app/components/manage/ocr-templates/ocr-templates.component.ts +++ b/src-ui/src/app/components/manage/ocr-templates/ocr-templates.component.ts @@ -90,7 +90,9 @@ export class OcrTemplatesComponent const editor: OcrTemplateEditorComponent = modal.componentInstance if (editor.saving()) return false return editor.isDirty - ? firstValueFrom(this.dirtyFormGuard.confirmChanges()) + ? firstValueFrom( + this.dirtyFormGuard.confirmChanges(undefined, $localize`Close`) + ) : true }, }) diff --git a/src-ui/src/app/guards/dirty-form.guard.ts b/src-ui/src/app/guards/dirty-form.guard.ts index b7bde9df4..39f18dc11 100644 --- a/src-ui/src/app/guards/dirty-form.guard.ts +++ b/src-ui/src/app/guards/dirty-form.guard.ts @@ -3,12 +3,16 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { DirtyCheckGuard } from '@ngneat/dirty-check-forms' import { Observable, Subject } from 'rxjs' import { ConfirmDialogComponent } from 'src/app/components/common/confirm-dialog/confirm-dialog.component' +import { ActivatedRouteSnapshot } from '@angular/router' @Injectable({ providedIn: 'root' }) export class DirtyFormGuard extends DirtyCheckGuard { private modalService = inject(NgbModal) - confirmChanges(): Observable { + confirmChanges( + _currentRoute?: ActivatedRouteSnapshot, + leaveLabel: string = $localize`Leave page` + ): Observable { let modal = this.modalService.open(ConfirmDialogComponent, { backdrop: 'static', }) @@ -16,7 +20,7 @@ export class DirtyFormGuard extends DirtyCheckGuard { modal.componentInstance.messageBold = $localize`You have unsaved changes.` modal.componentInstance.message = $localize`Are you sure you want to leave?` modal.componentInstance.btnClass = 'btn-warning' - modal.componentInstance.btnCaption = $localize`Leave page` + modal.componentInstance.btnCaption = leaveLabel modal.componentInstance.confirmClicked.subscribe(() => { modal.componentInstance.buttonsEnabled.set(false) modal.close()