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) {
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) {

View File

@ -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)
}
})
}

View File

@ -140,7 +140,7 @@
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group w-100">
@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>
</a>
<pngx-preview-popup [document]="document" #popupPreview>

View File

@ -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) {