mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-12 00:19:48 +00:00
Enhancement: document link field fixes (#5020)
* Implement more efficient getFew for document retrieval * Filter out parent document ID & already-selected documents * Clip very long document titles
This commit is contained in:
@@ -43,6 +43,9 @@ export class DocumentLinkComponent
|
||||
@Input()
|
||||
notFoundText: string = $localize`No documents found`
|
||||
|
||||
@Input()
|
||||
parentDocumentID: number
|
||||
|
||||
constructor(private documentsService: DocumentService) {
|
||||
super()
|
||||
}
|
||||
@@ -58,11 +61,11 @@ export class DocumentLinkComponent
|
||||
} else {
|
||||
this.loading = true
|
||||
this.documentsService
|
||||
.getCachedMany(documentIDs)
|
||||
.getFew(documentIDs, { fields: 'id,title' })
|
||||
.pipe(takeUntil(this.unsubscribeNotifier))
|
||||
.subscribe((documents) => {
|
||||
.subscribe((documentResults) => {
|
||||
this.loading = false
|
||||
this.selectedDocuments = documents
|
||||
this.selectedDocuments = documentResults.results
|
||||
super.writeValue(documentIDs)
|
||||
})
|
||||
}
|
||||
@@ -86,7 +89,13 @@ export class DocumentLinkComponent
|
||||
{ truncate_content: true }
|
||||
)
|
||||
.pipe(
|
||||
map((results) => results.results),
|
||||
map((results) =>
|
||||
results.results.filter(
|
||||
(d) =>
|
||||
d.id !== this.parentDocumentID &&
|
||||
!this.selectedDocuments.find((sd) => sd.id === d.id)
|
||||
)
|
||||
),
|
||||
catchError(() => of([])), // empty on error
|
||||
tap(() => (this.loading = false))
|
||||
)
|
||||
|
Reference in New Issue
Block a user