mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-08-04 10:02:17 +00:00
Fix compatibility with duplicate_of instead of duplicate_documents
This commit is contained in:
@@ -173,6 +173,12 @@
|
||||
@if (taskHasResultMessage(task) && !taskHasLongResultMessage(task)) {
|
||||
<span class="small d-none d-md-inline-block font-monospace text-muted">{{ taskResultMessage(task) }}</span>
|
||||
}
|
||||
@if (duplicateDocumentId(task)) {
|
||||
<div class="small text-warning-emphasis d-flex align-items-center gap-1 mt-1">
|
||||
<i-bs class="lh-1" width="1em" height="1em" name="exclamation-triangle"></i-bs>
|
||||
<span>{{ duplicateTaskLabel(task) }}</span>
|
||||
</div>
|
||||
}
|
||||
<ng-template #resultPopover>
|
||||
<pre class="small mb-0">{{ taskResultPopoverMessage(task) }}@if (taskResultMessageOverflowsPopover(task)) {
|
||||
…
|
||||
@@ -214,6 +220,23 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (duplicateDocumentId(task); as duplicateDocumentId) {
|
||||
<div class="detail-section mb-3">
|
||||
<div class="detail-label fs-7 fw-bold text-uppercase text-muted mb-1" i18n>Duplicate</div>
|
||||
<div class="detail-block border border-dark bg-body p-3 rounded-2 mb-0">
|
||||
<div class="d-flex align-items-center justify-content-between gap-3">
|
||||
<div class="text-break">{{ duplicateTaskLabel(task) }}</div>
|
||||
<button
|
||||
class="btn btn-sm btn-outline-primary"
|
||||
type="button"
|
||||
(click)="openDuplicateDocument(duplicateDocumentId)">
|
||||
<ng-container i18n>Open</ng-container>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-12 col-xl-6">
|
||||
<div class="detail-section h-100">
|
||||
|
||||
@@ -94,7 +94,7 @@ const tasks: PaperlessTask[] = [
|
||||
trigger_source_display: 'Email Consume',
|
||||
status: PaperlessTaskStatus.Success,
|
||||
status_display: 'Success',
|
||||
result_data: { document_id: 422 },
|
||||
result_data: { document_id: 422, duplicate_of: 99 },
|
||||
acknowledged: false,
|
||||
related_document_ids: [422],
|
||||
},
|
||||
@@ -344,6 +344,18 @@ describe('TasksComponent', () => {
|
||||
expect(detailText).toContain('"issues_found": 0')
|
||||
})
|
||||
|
||||
it('should show duplicate warnings and duplicate details when present', () => {
|
||||
component.setSection(TaskSection.Completed)
|
||||
component.expandTask(tasks[3])
|
||||
fixture.detectChanges()
|
||||
|
||||
const content = fixture.nativeElement.textContent
|
||||
|
||||
expect(content).toContain('Duplicate of document #99')
|
||||
expect(content).toContain('Duplicate')
|
||||
expect(content).toContain('Open')
|
||||
})
|
||||
|
||||
it('should support dismiss single task', () => {
|
||||
const dismissSpy = jest.spyOn(tasksService, 'dismissTasks')
|
||||
component.dismissTask(tasks[0])
|
||||
|
||||
@@ -371,7 +371,7 @@ export class TasksComponent
|
||||
|
||||
const duplicateOf = task.result_data?.['duplicate_of']
|
||||
if (typeof duplicateOf === 'number') {
|
||||
return `Not consuming: It is a duplicate of document #${duplicateOf}`
|
||||
return `Duplicate of document #${duplicateOf}`
|
||||
}
|
||||
|
||||
const errorMessage = task.result_data?.['error_message']
|
||||
@@ -399,6 +399,19 @@ export class TasksComponent
|
||||
return !!this.taskResultMessage(task)
|
||||
}
|
||||
|
||||
duplicateDocumentId(task: PaperlessTask): number | null {
|
||||
const duplicateOf = task.result_data?.['duplicate_of']
|
||||
return typeof duplicateOf === 'number' ? duplicateOf : null
|
||||
}
|
||||
|
||||
duplicateTaskLabel(task: PaperlessTask): string {
|
||||
return $localize`Duplicate of document #${this.duplicateDocumentId(task)}`
|
||||
}
|
||||
|
||||
openDuplicateDocument(documentId: number) {
|
||||
this.router.navigate(['documents', documentId, 'details'])
|
||||
}
|
||||
|
||||
taskResultPopoverMessage(task: PaperlessTask): string {
|
||||
return this.taskResultMessage(task)?.slice(0, 300) ?? ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user