Implement warning for closeAll

This commit is contained in:
Michael Shamoon
2021-01-26 22:27:50 -08:00
parent d275a75517
commit 1950f805b3
3 changed files with 50 additions and 17 deletions

View File

@@ -25,9 +25,7 @@ export class AppFrameComponent implements OnInit, OnDestroy {
private searchService: SearchService,
public savedViewService: SavedViewService,
private meta: Meta
) {
}
) { }
versionString = `${environment.appTitle} ${environment.version}`
@@ -78,17 +76,21 @@ export class AppFrameComponent implements OnInit, OnDestroy {
}
closeAll() {
this.closeMenu()
this.openDocumentsService.closeAll()
// user may need to confirm losing unsaved changes
this.openDocumentsService.closeAll().subscribe(confirmed => {
if (confirmed) {
this.closeMenu()
// TODO: is there a better way to do this?
let route = this.activatedRoute
while (route.firstChild) {
route = route.firstChild
}
if (route.component == DocumentDetailComponent) {
this.router.navigate([""])
}
// TODO: is there a better way to do this?
let route = this.activatedRoute
while (route.firstChild) {
route = route.firstChild
}
if (route.component == DocumentDetailComponent) {
this.router.navigate([""])
}
}
})
}
ngOnInit() {

View File

@@ -136,6 +136,9 @@ export class DocumentDetailComponent implements OnInit, DirtyComponent {
// Initialize dirtyCheck
this.isDirty$ = dirtyCheck(this.documentForm, this.store.asObservable())
this.isDirty$.subscribe(dirty => {
this.openDocumentService.setDirty(this.document.id, dirty)
})
}
createDocumentType() {