mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-11 23:59:31 -06:00
head --> root to avoid confusion, prevent root deletion
[ci skip]
This commit is contained in:
@@ -87,16 +87,18 @@
|
||||
</div>
|
||||
</button>
|
||||
@if (selectedVersionId === version.id) { <span class="ms-2">✓</span> }
|
||||
<pngx-confirm-button
|
||||
buttonClasses="btn-link btn-sm text-danger ms-2"
|
||||
iconName="trash"
|
||||
confirmMessage="Delete this version?"
|
||||
i18n-confirmMessage
|
||||
[disabled]="!userIsOwner || !userCanEdit"
|
||||
(confirm)="deleteVersion(version.id)"
|
||||
>
|
||||
<span class="visually-hidden" i18n>Delete version</span>
|
||||
</pngx-confirm-button>
|
||||
@if (!version.is_root) {
|
||||
<pngx-confirm-button
|
||||
buttonClasses="btn-link btn-sm text-danger ms-2"
|
||||
iconName="trash"
|
||||
confirmMessage="Delete this version?"
|
||||
i18n-confirmMessage
|
||||
[disabled]="!userIsOwner || !userCanEdit"
|
||||
(confirm)="deleteVersion(version.id)"
|
||||
>
|
||||
<span class="visually-hidden" i18n>Delete version</span>
|
||||
</pngx-confirm-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ export class DocumentDetailComponent
|
||||
}
|
||||
|
||||
private loadDocument(documentId: number): void {
|
||||
let redirectedToHead = false
|
||||
let redirectedToRoot = false
|
||||
this.selectedVersionId = documentId
|
||||
this.previewUrl = this.documentsService.getPreviewUrl(
|
||||
this.selectedVersionId
|
||||
@@ -477,14 +477,14 @@ export class DocumentDetailComponent
|
||||
.pipe(
|
||||
catchError((error) => {
|
||||
if (error?.status === 404) {
|
||||
return this.documentsService.getHeadId(documentId).pipe(
|
||||
return this.documentsService.getRootId(documentId).pipe(
|
||||
map((result) => {
|
||||
const headId = result?.head_id
|
||||
if (headId && headId !== documentId) {
|
||||
const rootId = result?.root_id
|
||||
if (rootId && rootId !== documentId) {
|
||||
const section =
|
||||
this.route.snapshot.paramMap.get('section') || 'details'
|
||||
redirectedToHead = true
|
||||
this.router.navigate(['documents', headId, section], {
|
||||
redirectedToRoot = true
|
||||
this.router.navigate(['documents', rootId, section], {
|
||||
replaceUrl: true,
|
||||
})
|
||||
}
|
||||
@@ -503,7 +503,7 @@ export class DocumentDetailComponent
|
||||
.subscribe({
|
||||
next: (doc) => {
|
||||
if (!doc) {
|
||||
if (redirectedToHead) {
|
||||
if (redirectedToRoot) {
|
||||
return
|
||||
}
|
||||
this.router.navigate(['404'], { replaceUrl: true })
|
||||
@@ -786,8 +786,6 @@ export class DocumentDetailComponent
|
||||
}
|
||||
|
||||
getVersionBadge(version: DocumentVersionInfo): string {
|
||||
console.log(version)
|
||||
|
||||
const checksum = version?.checksum ?? ''
|
||||
if (!checksum) return '----'
|
||||
return checksum.slice(0, 4).toUpperCase()
|
||||
|
||||
Reference in New Issue
Block a user