mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-11 23:59:31 -06:00
Delete version ui
This commit is contained in:
@@ -19,12 +19,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
@for (version of document.versions; track version.id) {
|
@for (version of document.versions; track version.id) {
|
||||||
<button ngbDropdownItem (click)="selectVersion(version.id)">
|
<div class="dropdown-item">
|
||||||
<div class="d-flex align-items-center w-100 version-item">
|
<div class="d-flex align-items-center w-100 version-item">
|
||||||
<span class="badge bg-light text-lowercase text-muted">
|
<span class="badge bg-light text-lowercase text-muted">
|
||||||
{{ version.checksum | slice:0:8 }}
|
{{ version.checksum | slice:0:8 }}
|
||||||
</span>
|
</span>
|
||||||
<div class="flex-grow-1 ms-3 small">
|
<button type="button" class="version-entry flex-grow-1 ms-3 small text-start" (click)="selectVersion(version.id)">
|
||||||
<div class="small">
|
<div class="small">
|
||||||
@if (version.label) {
|
@if (version.label) {
|
||||||
{{ version.label }}
|
{{ version.label }}
|
||||||
@@ -35,10 +35,20 @@
|
|||||||
<div class="version-subtitle text-muted">
|
<div class="version-subtitle text-muted">
|
||||||
{{ version.added | customDate:'short' }}
|
{{ version.added | customDate:'short' }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</button>
|
||||||
@if (selectedVersionId === version.id) { <span class="ms-2">✓</span> }
|
@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>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -85,3 +85,9 @@ textarea.rtl {
|
|||||||
object-position: top;
|
object-position: top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.version-entry {
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ import { getFilenameFromContentDisposition } from 'src/app/utils/http'
|
|||||||
import { ISODateAdapter } from 'src/app/utils/ngb-iso-date-adapter'
|
import { ISODateAdapter } from 'src/app/utils/ngb-iso-date-adapter'
|
||||||
import * as UTIF from 'utif'
|
import * as UTIF from 'utif'
|
||||||
import { DocumentDetailFieldID } from '../admin/settings/settings.component'
|
import { DocumentDetailFieldID } from '../admin/settings/settings.component'
|
||||||
|
import { ConfirmButtonComponent } from '../common/confirm-button/confirm-button.component'
|
||||||
import { ConfirmDialogComponent } from '../common/confirm-dialog/confirm-dialog.component'
|
import { ConfirmDialogComponent } from '../common/confirm-dialog/confirm-dialog.component'
|
||||||
import { PasswordRemovalConfirmDialogComponent } from '../common/confirm-dialog/password-removal-confirm-dialog/password-removal-confirm-dialog.component'
|
import { PasswordRemovalConfirmDialogComponent } from '../common/confirm-dialog/password-removal-confirm-dialog/password-removal-confirm-dialog.component'
|
||||||
import { CustomFieldsDropdownComponent } from '../common/custom-fields-dropdown/custom-fields-dropdown.component'
|
import { CustomFieldsDropdownComponent } from '../common/custom-fields-dropdown/custom-fields-dropdown.component'
|
||||||
@@ -176,6 +177,7 @@ enum ContentRenderType {
|
|||||||
TextAreaComponent,
|
TextAreaComponent,
|
||||||
RouterModule,
|
RouterModule,
|
||||||
PngxPdfViewerComponent,
|
PngxPdfViewerComponent,
|
||||||
|
ConfirmButtonComponent,
|
||||||
SlicePipe,
|
SlicePipe,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@@ -771,6 +773,24 @@ export class DocumentDetailComponent
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteVersion(versionId: number) {
|
||||||
|
const wasSelected = this.selectedVersionId === versionId
|
||||||
|
this.documentsService
|
||||||
|
.deleteVersion(this.documentId, versionId)
|
||||||
|
.pipe(first(), takeUntil(this.unsubscribeNotifier))
|
||||||
|
.subscribe({
|
||||||
|
next: (result) => {
|
||||||
|
if (wasSelected && result?.current_version_id) {
|
||||||
|
this.selectVersion(result.current_version_id)
|
||||||
|
}
|
||||||
|
this.openDocumentService.refreshDocument(this.documentId)
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
this.toastService.showError($localize`Error deleting version`, error)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
get customFieldFormFields(): FormArray {
|
get customFieldFormFields(): FormArray {
|
||||||
return this.documentForm.get('custom_fields') as FormArray
|
return this.documentForm.get('custom_fields') as FormArray
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,6 +204,12 @@ export class DocumentService extends AbstractPaperlessService<Document> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteVersion(headDocumentId: number, versionId: number) {
|
||||||
|
return this.http.delete<{ result: string; current_version_id: number }>(
|
||||||
|
this.getResourceUrl(headDocumentId, `versions/${versionId}`)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
getNextAsn(): Observable<number> {
|
getNextAsn(): Observable<number> {
|
||||||
return this.http.get<number>(this.getResourceUrl(null, 'next_asn'))
|
return this.http.get<number>(this.getResourceUrl(null, 'next_asn'))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user