From 0c9996d81ced7414e61799e69e094364961f8602 Mon Sep 17 00:00:00 2001 From: Alisan Stoll <23653980+inc-ali@users.noreply.github.com> Date: Tue, 28 Jan 2025 23:41:28 +0000 Subject: [PATCH] feat: return to previous view after editing document (#8879) --- .../src/app/components/admin/tasks/tasks.component.ts | 4 +++- .../document-detail/document-detail.component.ts | 6 +++++- .../document-card-small.component.html | 2 +- .../document-card-small.component.ts | 11 +++++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) 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 @@