mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
fixed some issues with the data access service, support for requesting all IDs of filtered documents (required for selection)
This commit is contained in:
parent
63a58ccc38
commit
2c702eb568
@ -90,7 +90,7 @@ export class DocumentListViewService {
|
||||
|
||||
reload(onFinish?) {
|
||||
this.isReloading = true
|
||||
this.documentService.list(
|
||||
this.documentService.listFiltered(
|
||||
this.currentPage,
|
||||
this.currentPageSize,
|
||||
this.view.sortField,
|
||||
|
@ -54,9 +54,9 @@ export abstract class AbstractPaperlessService<T extends ObjectWithId> {
|
||||
|
||||
private _listAll: Observable<Results<T>>
|
||||
|
||||
listAll(ordering?: string, extraParams?): Observable<Results<T>> {
|
||||
listAll(sortField?: string, sortDirection?: string, extraParams?): Observable<Results<T>> {
|
||||
if (!this._listAll) {
|
||||
this._listAll = this.list(1, 100000, ordering, extraParams).pipe(
|
||||
this._listAll = this.list(1, 100000, sortField, sortDirection, extraParams).pipe(
|
||||
publishReplay(1),
|
||||
refCount()
|
||||
)
|
||||
@ -94,4 +94,4 @@ export abstract class AbstractPaperlessService<T extends ObjectWithId> {
|
||||
this._listAll = null
|
||||
return this.http.put<T>(this.getResourceUrl(o.id), o)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
|
||||
return doc
|
||||
}
|
||||
|
||||
list(page?: number, pageSize?: number, sortField?: string, sortDirection?: string, filterRules?: FilterRule[]): Observable<Results<PaperlessDocument>> {
|
||||
return super.list(page, pageSize, sortField, sortDirection, this.filterRulesToQueryParams(filterRules)).pipe(
|
||||
listFiltered(page?: number, pageSize?: number, sortField?: string, sortDirection?: string, filterRules?: FilterRule[], extraParams = {}): Observable<Results<PaperlessDocument>> {
|
||||
return this.list(page, pageSize, sortField, sortDirection, Object.assign(extraParams, this.filterRulesToQueryParams(filterRules))).pipe(
|
||||
map(results => {
|
||||
results.results.forEach(doc => this.addObservablesToDocument(doc))
|
||||
return results
|
||||
@ -73,6 +73,12 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
|
||||
)
|
||||
}
|
||||
|
||||
listAllFilteredIds(filterRules?: FilterRule[]): Observable<number[]> {
|
||||
return this.listFiltered(1, 100000, null, null, filterRules, {"fields": "id"}).pipe(
|
||||
map(response => response.results.map(doc => doc.id))
|
||||
)
|
||||
}
|
||||
|
||||
getPreviewUrl(id: number, original: boolean = false): string {
|
||||
let url = this.getResourceUrl(id, 'preview')
|
||||
if (original) {
|
||||
@ -101,11 +107,11 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
|
||||
return this.http.get<PaperlessDocumentMetadata>(this.getResourceUrl(id, 'metadata'))
|
||||
}
|
||||
|
||||
bulk_edit(ids: number[], method: string, args: any[]) {
|
||||
bulkEdit(ids: number[], method: string, args: any) {
|
||||
return this.http.post(this.getResourceUrl(null, 'bulk_edit'), {
|
||||
'ids': ids,
|
||||
'documents': ids,
|
||||
'method': method,
|
||||
'args': args
|
||||
'parameters': args
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user