diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts index fb7c20776f..02221ea263 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -381,7 +381,7 @@ export class BulkEditorComponent } this.documentService - .getSelectionData(Array.from(this.list.selected)) + .getSelectionData({ documents: Array.from(this.list.selected) }) .pipe(first()) .subscribe((s) => { this.tagDocumentCounts.set(s.selected_tags) @@ -403,7 +403,7 @@ export class BulkEditorComponent } this.documentService - .getSelectionData(Array.from(this.list.selected)) + .getSelectionData({ documents: Array.from(this.list.selected) }) .pipe(first()) .subscribe((s) => { this.documentTypeDocumentCounts.set(s.selected_document_types) @@ -428,7 +428,7 @@ export class BulkEditorComponent } this.documentService - .getSelectionData(Array.from(this.list.selected)) + .getSelectionData({ documents: Array.from(this.list.selected) }) .pipe(first()) .subscribe((s) => { this.correspondentDocumentCounts.set(s.selected_correspondents) @@ -453,7 +453,7 @@ export class BulkEditorComponent } this.documentService - .getSelectionData(Array.from(this.list.selected)) + .getSelectionData({ documents: Array.from(this.list.selected) }) .pipe(first()) .subscribe((s) => { this.storagePathDocumentCounts.set(s.selected_storage_paths) @@ -478,7 +478,7 @@ export class BulkEditorComponent } this.documentService - .getSelectionData(Array.from(this.list.selected)) + .getSelectionData({ documents: Array.from(this.list.selected) }) .pipe(first()) .subscribe((s) => { this.customFieldDocumentCounts.set(s.selected_custom_fields) diff --git a/src-ui/src/app/services/rest/document.service.spec.ts b/src-ui/src/app/services/rest/document.service.spec.ts index fbb763c46e..4250d8e84f 100644 --- a/src-ui/src/app/services/rest/document.service.spec.ts +++ b/src-ui/src/app/services/rest/document.service.spec.ts @@ -175,7 +175,7 @@ describe(`DocumentService`, () => { it('should call appropriate api endpoint for getting selection data', () => { const ids = [documents[0].id] - subscription = service.getSelectionData(ids).subscribe() + subscription = service.getSelectionData({ documents: ids }).subscribe() const req = httpTestingController.expectOne( `${environment.apiBaseUrl}${endpoint}/selection_data/` ) @@ -185,6 +185,20 @@ describe(`DocumentService`, () => { }) }) + it('should get selection data with all, filters, and exclusions', () => { + const selection = { + all: true, + filters: { title__icontains: 'apple' }, + excluded_documents: [2, 3], + } + subscription = service.getSelectionData(selection).subscribe() + const req = httpTestingController.expectOne( + `${environment.apiBaseUrl}${endpoint}/selection_data/` + ) + expect(req.request.method).toEqual('POST') + expect(req.request.body).toEqual(selection) + }) + it('should call appropriate api endpoint for getting suggestions', () => { subscription = service.getSuggestions(documents[0].id).subscribe() const req = httpTestingController.expectOne( @@ -240,7 +254,7 @@ describe(`DocumentService`, () => { }) }) - it('should call appropriate api endpoint for bulk edit with all and filters', () => { + it('should call appropriate api endpoint for bulk edit with all, filters, and exclusions', () => { const method = 'modify_tags' const parameters = { add_tags: [15], @@ -249,6 +263,7 @@ describe(`DocumentService`, () => { const selection = { all: true, filters: { title__icontains: 'apple' }, + excluded_documents: [2, 3], } subscription = service.bulkEdit(selection, method, parameters).subscribe() const req = httpTestingController.expectOne( @@ -258,6 +273,7 @@ describe(`DocumentService`, () => { expect(req.request.body).toEqual({ all: true, filters: { title__icontains: 'apple' }, + excluded_documents: [2, 3], method, parameters, }) diff --git a/src-ui/src/app/services/rest/document.service.ts b/src-ui/src/app/services/rest/document.service.ts index 92ba21d330..3272d9695e 100644 --- a/src-ui/src/app/services/rest/document.service.ts +++ b/src-ui/src/app/services/rest/document.service.ts @@ -72,6 +72,7 @@ export interface DocumentSelectionQuery { documents?: number[] all?: boolean filters?: { [key: string]: any } + excluded_documents?: number[] } @Injectable({ @@ -407,10 +408,12 @@ export class DocumentService extends AbstractPaperlessService { }) } - getSelectionData(ids: number[]): Observable { + getSelectionData( + selection: DocumentSelectionQuery + ): Observable { return this.http.post( this.getResourceUrl(null, 'selection_data'), - { documents: ids } + selection ) }