feat: return to previous view after editing document (#8879)

This commit is contained in:
Alisan Stoll 2025-01-28 23:41:28 +00:00
parent 9c6f695dbf
commit 0c9996d81c
4 changed files with 18 additions and 5 deletions

View File

@ -169,7 +169,9 @@ export class TasksComponent
dismissAndGo(task: PaperlessTask) { dismissAndGo(task: PaperlessTask) {
this.dismissTask(task) 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) { expandTask(task: PaperlessTask) {

View File

@ -254,6 +254,7 @@ export class DocumentDetailComponent
DocumentDetailNavIDs = DocumentDetailNavIDs DocumentDetailNavIDs = DocumentDetailNavIDs
activeNavID: number activeNavID: number
previousUrl: string
constructor( constructor(
private documentsService: DocumentService, private documentsService: DocumentService,
@ -275,6 +276,9 @@ export class DocumentDetailComponent
private hotKeyService: HotKeyService private hotKeyService: HotKeyService
) { ) {
super() super()
let previousUrl = router.getCurrentNavigation()?.extras?.state?.previousUrl
this.previousUrl = previousUrl ? previousUrl : '/'
} }
titleKeyUp(event) { titleKeyUp(event) {
@ -889,7 +893,7 @@ export class DocumentDetailComponent
this.documentListViewService.activeSavedViewId, this.documentListViewService.activeSavedViewId,
]) ])
} else { } else {
this.router.navigate(['documents']) this.router.navigateByUrl(this.previousUrl)
} }
}) })
} }

View File

@ -140,7 +140,7 @@
<div class="d-flex justify-content-between align-items-center"> <div class="d-flex justify-content-between align-items-center">
<div class="btn-group w-100"> <div class="btn-group w-100">
@if (document) { @if (document) {
<a routerLink="/documents/{{document.id}}" class="btn btn-sm btn-outline-secondary" title="Open" i18n-title *pngxIfPermissions="{ action: PermissionAction.Change, type: PermissionType.Document }" i18n-title> <a (click)="openDocumentDetail(document.id)" class="btn btn-sm btn-outline-secondary" title="Open" i18n-title *pngxIfPermissions="{ action: PermissionAction.Change, type: PermissionType.Document }" i18n-title>
<i-bs name="file-earmark-richtext"></i-bs> <i-bs name="file-earmark-richtext"></i-bs>
</a> </a>
<pngx-preview-popup [document]="document" #popupPreview> <pngx-preview-popup [document]="document" #popupPreview>

View File

@ -7,7 +7,7 @@ import {
Output, Output,
ViewChild, ViewChild,
} from '@angular/core' } from '@angular/core'
import { RouterModule } from '@angular/router' import { Router, RouterModule } from '@angular/router'
import { import {
NgbProgressbarModule, NgbProgressbarModule,
NgbTooltipModule, NgbTooltipModule,
@ -67,7 +67,8 @@ export class DocumentCardSmallComponent
constructor( constructor(
private documentService: DocumentService, private documentService: DocumentService,
public settingsService: SettingsService public settingsService: SettingsService,
private router: Router
) { ) {
super() super()
} }
@ -123,6 +124,12 @@ export class DocumentCardSmallComponent
return this.documentService.getDownloadUrl(this.document.id) return this.documentService.getDownloadUrl(this.document.id)
} }
openDocumentDetail(documentId) {
this.router.navigate(['/documents', documentId, 'details'], {
state: { previousUrl: this.router.url },
})
}
get tagIDs() { get tagIDs() {
const limit = this.document.notes.length > 0 ? 6 : 7 const limit = this.document.notes.length > 0 ? 6 : 7
if (this.document.tags.length > limit) { if (this.document.tags.length > limit) {