Support empty all
This commit is contained in:
@@ -66,7 +66,7 @@ export class TrashComponent implements OnDestroy {
|
||||
})
|
||||
}
|
||||
|
||||
emptyTrash(documents: Set<number> = null) {
|
||||
emptyTrash(documents?: Set<number>) {
|
||||
let modal = this.modalService.open(ConfirmDialogComponent, {
|
||||
backdrop: 'static',
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '@angular/common/http/testing'
|
||||
import { environment } from 'src/environments/environment'
|
||||
|
||||
describe('TrashServiceService', () => {
|
||||
describe('TrashService', () => {
|
||||
let service: TrashService
|
||||
let httpTestingController: HttpTestingController
|
||||
|
||||
@@ -33,7 +33,16 @@ describe('TrashServiceService', () => {
|
||||
`${environment.apiBaseUrl}trash/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
expect(req.request.body).toEqual({ action: 'empty', documents: [] })
|
||||
expect(req.request.body).toEqual({ action: 'empty' })
|
||||
|
||||
service.emptyTrash([1, 2, 3]).subscribe()
|
||||
const req2 = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}trash/`
|
||||
)
|
||||
expect(req2.request.body).toEqual({
|
||||
action: 'empty',
|
||||
documents: [1, 2, 3],
|
||||
})
|
||||
})
|
||||
|
||||
it('should call correct endpoint for restoreDocuments', () => {
|
||||
|
||||
@@ -18,11 +18,14 @@ export class TrashService {
|
||||
})
|
||||
}
|
||||
|
||||
public emptyTrash(documents: number[] = []): Observable<any> {
|
||||
return this.http.post(`${environment.apiBaseUrl}trash/`, {
|
||||
public emptyTrash(documents?: number[]): Observable<any> {
|
||||
const data = {
|
||||
action: 'empty',
|
||||
documents,
|
||||
})
|
||||
}
|
||||
if (documents?.length) {
|
||||
data['documents'] = documents
|
||||
}
|
||||
return this.http.post(`${environment.apiBaseUrl}trash/`, data)
|
||||
}
|
||||
|
||||
public restoreDocuments(documents: number[]): Observable<any> {
|
||||
|
||||
Reference in New Issue
Block a user