mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-17 10:13:56 -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?) {
|
reload(onFinish?) {
|
||||||
this.isReloading = true
|
this.isReloading = true
|
||||||
this.documentService.list(
|
this.documentService.listFiltered(
|
||||||
this.currentPage,
|
this.currentPage,
|
||||||
this.currentPageSize,
|
this.currentPageSize,
|
||||||
this.view.sortField,
|
this.view.sortField,
|
||||||
|
@ -54,9 +54,9 @@ export abstract class AbstractPaperlessService<T extends ObjectWithId> {
|
|||||||
|
|
||||||
private _listAll: Observable<Results<T>>
|
private _listAll: Observable<Results<T>>
|
||||||
|
|
||||||
listAll(ordering?: string, extraParams?): Observable<Results<T>> {
|
listAll(sortField?: string, sortDirection?: string, extraParams?): Observable<Results<T>> {
|
||||||
if (!this._listAll) {
|
if (!this._listAll) {
|
||||||
this._listAll = this.list(1, 100000, ordering, extraParams).pipe(
|
this._listAll = this.list(1, 100000, sortField, sortDirection, extraParams).pipe(
|
||||||
publishReplay(1),
|
publishReplay(1),
|
||||||
refCount()
|
refCount()
|
||||||
)
|
)
|
||||||
|
@ -64,8 +64,8 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
|
|||||||
return doc
|
return doc
|
||||||
}
|
}
|
||||||
|
|
||||||
list(page?: number, pageSize?: number, sortField?: string, sortDirection?: string, filterRules?: FilterRule[]): Observable<Results<PaperlessDocument>> {
|
listFiltered(page?: number, pageSize?: number, sortField?: string, sortDirection?: string, filterRules?: FilterRule[], extraParams = {}): Observable<Results<PaperlessDocument>> {
|
||||||
return super.list(page, pageSize, sortField, sortDirection, this.filterRulesToQueryParams(filterRules)).pipe(
|
return this.list(page, pageSize, sortField, sortDirection, Object.assign(extraParams, this.filterRulesToQueryParams(filterRules))).pipe(
|
||||||
map(results => {
|
map(results => {
|
||||||
results.results.forEach(doc => this.addObservablesToDocument(doc))
|
results.results.forEach(doc => this.addObservablesToDocument(doc))
|
||||||
return results
|
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 {
|
getPreviewUrl(id: number, original: boolean = false): string {
|
||||||
let url = this.getResourceUrl(id, 'preview')
|
let url = this.getResourceUrl(id, 'preview')
|
||||||
if (original) {
|
if (original) {
|
||||||
@ -101,11 +107,11 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
|
|||||||
return this.http.get<PaperlessDocumentMetadata>(this.getResourceUrl(id, 'metadata'))
|
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'), {
|
return this.http.post(this.getResourceUrl(null, 'bulk_edit'), {
|
||||||
'ids': ids,
|
'documents': ids,
|
||||||
'method': method,
|
'method': method,
|
||||||
'args': args
|
'parameters': args
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user