Implement warning for closeAll

This commit is contained in:
Michael Shamoon
2021-01-26 22:27:50 -08:00
parent 16d626d5ca
commit 9887233c83
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() {