Make it close not leave page

This commit is contained in:
shamoon committed 2026-10-20 09:38:29 -07:00
1 parent 0572b54579
commit ea31b6a043
2 files changed
+9 -3

No files matched your search

@@ -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
},
})
+6 -2
View File
@@ -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<boolean> {
confirmChanges(
_currentRoute?: ActivatedRouteSnapshot,
leaveLabel: string = $localize`Leave page`
): Observable<boolean> {
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()