diff --git a/src-ui/src/app/components/admin/tasks/tasks.component.ts b/src-ui/src/app/components/admin/tasks/tasks.component.ts index d97bdc29b..e915765c2 100644 --- a/src-ui/src/app/components/admin/tasks/tasks.component.ts +++ b/src-ui/src/app/components/admin/tasks/tasks.component.ts @@ -169,7 +169,9 @@ export class TasksComponent dismissAndGo(task: PaperlessTask) { this.dismissTask(task) - this.router.navigate(['documents', task.related_document]) + this.router.navigate(['documents', task.related_document, 'details'], { + state: { previousUrl: this.router.url }, + }) } expandTask(task: PaperlessTask) { diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 6b65ad335..9c6602325 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -254,6 +254,7 @@ export class DocumentDetailComponent DocumentDetailNavIDs = DocumentDetailNavIDs activeNavID: number + previousUrl: string constructor( private documentsService: DocumentService, @@ -275,6 +276,9 @@ export class DocumentDetailComponent private hotKeyService: HotKeyService ) { super() + + let previousUrl = router.getCurrentNavigation()?.extras?.state?.previousUrl + this.previousUrl = previousUrl ? previousUrl : '/' } titleKeyUp(event) { @@ -889,7 +893,7 @@ export class DocumentDetailComponent this.documentListViewService.activeSavedViewId, ]) } else { - this.router.navigate(['documents']) + this.router.navigateByUrl(this.previousUrl) } }) } diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html index a166acd94..26b52c14d 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html @@ -140,7 +140,7 @@
@if (document) { - + diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts index 6e4e3943e..d416c5912 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts @@ -7,7 +7,7 @@ import { Output, ViewChild, } from '@angular/core' -import { RouterModule } from '@angular/router' +import { Router, RouterModule } from '@angular/router' import { NgbProgressbarModule, NgbTooltipModule, @@ -67,7 +67,8 @@ export class DocumentCardSmallComponent constructor( private documentService: DocumentService, - public settingsService: SettingsService + public settingsService: SettingsService, + private router: Router ) { super() } @@ -123,6 +124,12 @@ export class DocumentCardSmallComponent return this.documentService.getDownloadUrl(this.document.id) } + openDocumentDetail(documentId) { + this.router.navigate(['/documents', documentId, 'details'], { + state: { previousUrl: this.router.url }, + }) + } + get tagIDs() { const limit = this.document.notes.length > 0 ? 6 : 7 if (this.document.tags.length > limit) {