mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-20 12:36:53 +00:00
Super basic frontend plumbing
This commit is contained in:
3 files changed
+28
-9
No files matched your search
@@ -381,7 +381,7 @@ export class BulkEditorComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.documentService
|
this.documentService
|
||||||
.getSelectionData(Array.from(this.list.selected))
|
.getSelectionData({ documents: Array.from(this.list.selected) })
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe((s) => {
|
.subscribe((s) => {
|
||||||
this.tagDocumentCounts.set(s.selected_tags)
|
this.tagDocumentCounts.set(s.selected_tags)
|
||||||
@@ -403,7 +403,7 @@ export class BulkEditorComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.documentService
|
this.documentService
|
||||||
.getSelectionData(Array.from(this.list.selected))
|
.getSelectionData({ documents: Array.from(this.list.selected) })
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe((s) => {
|
.subscribe((s) => {
|
||||||
this.documentTypeDocumentCounts.set(s.selected_document_types)
|
this.documentTypeDocumentCounts.set(s.selected_document_types)
|
||||||
@@ -428,7 +428,7 @@ export class BulkEditorComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.documentService
|
this.documentService
|
||||||
.getSelectionData(Array.from(this.list.selected))
|
.getSelectionData({ documents: Array.from(this.list.selected) })
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe((s) => {
|
.subscribe((s) => {
|
||||||
this.correspondentDocumentCounts.set(s.selected_correspondents)
|
this.correspondentDocumentCounts.set(s.selected_correspondents)
|
||||||
@@ -453,7 +453,7 @@ export class BulkEditorComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.documentService
|
this.documentService
|
||||||
.getSelectionData(Array.from(this.list.selected))
|
.getSelectionData({ documents: Array.from(this.list.selected) })
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe((s) => {
|
.subscribe((s) => {
|
||||||
this.storagePathDocumentCounts.set(s.selected_storage_paths)
|
this.storagePathDocumentCounts.set(s.selected_storage_paths)
|
||||||
@@ -478,7 +478,7 @@ export class BulkEditorComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.documentService
|
this.documentService
|
||||||
.getSelectionData(Array.from(this.list.selected))
|
.getSelectionData({ documents: Array.from(this.list.selected) })
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe((s) => {
|
.subscribe((s) => {
|
||||||
this.customFieldDocumentCounts.set(s.selected_custom_fields)
|
this.customFieldDocumentCounts.set(s.selected_custom_fields)
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ describe(`DocumentService`, () => {
|
|||||||
|
|
||||||
it('should call appropriate api endpoint for getting selection data', () => {
|
it('should call appropriate api endpoint for getting selection data', () => {
|
||||||
const ids = [documents[0].id]
|
const ids = [documents[0].id]
|
||||||
subscription = service.getSelectionData(ids).subscribe()
|
subscription = service.getSelectionData({ documents: ids }).subscribe()
|
||||||
const req = httpTestingController.expectOne(
|
const req = httpTestingController.expectOne(
|
||||||
`${environment.apiBaseUrl}${endpoint}/selection_data/`
|
`${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', () => {
|
it('should call appropriate api endpoint for getting suggestions', () => {
|
||||||
subscription = service.getSuggestions(documents[0].id).subscribe()
|
subscription = service.getSuggestions(documents[0].id).subscribe()
|
||||||
const req = httpTestingController.expectOne(
|
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 method = 'modify_tags'
|
||||||
const parameters = {
|
const parameters = {
|
||||||
add_tags: [15],
|
add_tags: [15],
|
||||||
@@ -249,6 +263,7 @@ describe(`DocumentService`, () => {
|
|||||||
const selection = {
|
const selection = {
|
||||||
all: true,
|
all: true,
|
||||||
filters: { title__icontains: 'apple' },
|
filters: { title__icontains: 'apple' },
|
||||||
|
excluded_documents: [2, 3],
|
||||||
}
|
}
|
||||||
subscription = service.bulkEdit(selection, method, parameters).subscribe()
|
subscription = service.bulkEdit(selection, method, parameters).subscribe()
|
||||||
const req = httpTestingController.expectOne(
|
const req = httpTestingController.expectOne(
|
||||||
@@ -258,6 +273,7 @@ describe(`DocumentService`, () => {
|
|||||||
expect(req.request.body).toEqual({
|
expect(req.request.body).toEqual({
|
||||||
all: true,
|
all: true,
|
||||||
filters: { title__icontains: 'apple' },
|
filters: { title__icontains: 'apple' },
|
||||||
|
excluded_documents: [2, 3],
|
||||||
method,
|
method,
|
||||||
parameters,
|
parameters,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ export interface DocumentSelectionQuery {
|
|||||||
documents?: number[]
|
documents?: number[]
|
||||||
all?: boolean
|
all?: boolean
|
||||||
filters?: { [key: string]: any }
|
filters?: { [key: string]: any }
|
||||||
|
excluded_documents?: number[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@@ -407,10 +408,12 @@ export class DocumentService extends AbstractPaperlessService<Document> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelectionData(ids: number[]): Observable<SelectionData> {
|
getSelectionData(
|
||||||
|
selection: DocumentSelectionQuery
|
||||||
|
): Observable<SelectionData> {
|
||||||
return this.http.post<SelectionData>(
|
return this.http.post<SelectionData>(
|
||||||
this.getResourceUrl(null, 'selection_data'),
|
this.getResourceUrl(null, 'selection_data'),
|
||||||
{ documents: ids }
|
selection
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user