mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-14 02:27:06 +01:00
Enhancement: bulk edit object permissions (#4176)
* bulk_edit_object_perms API endpoint * Frontend support for bulk object permissions edit
This commit is contained in:
parent
95c12c1840
commit
f5717cca1c
12 changed files with 540 additions and 20 deletions
|
|
@ -39,6 +39,31 @@ export const commonAbstractNameFilterPaperlessServiceTests = (
|
|||
expect(req.request.method).toEqual('GET')
|
||||
req.flush([])
|
||||
})
|
||||
|
||||
test('should call appropriate api endpoint for bulk permissions edit', () => {
|
||||
const owner = 3
|
||||
const permissions = {
|
||||
view: {
|
||||
users: [],
|
||||
groups: [3],
|
||||
},
|
||||
change: {
|
||||
users: [12, 13],
|
||||
groups: [],
|
||||
},
|
||||
}
|
||||
subscription = service
|
||||
.bulk_update_permissions([1, 2], {
|
||||
owner,
|
||||
set_permissions: permissions,
|
||||
})
|
||||
.subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}bulk_edit_object_perms/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
req.flush([])
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { ObjectWithId } from 'src/app/data/object-with-id'
|
||||
import { AbstractPaperlessService } from './abstract-paperless-service'
|
||||
import { PermissionsObject } from 'src/app/data/object-with-permissions'
|
||||
import { Observable } from 'rxjs'
|
||||
|
||||
export abstract class AbstractNameFilterService<
|
||||
T extends ObjectWithId,
|
||||
|
|
@ -21,4 +23,16 @@ export abstract class AbstractNameFilterService<
|
|||
}
|
||||
return this.list(page, pageSize, sortField, sortReverse, params)
|
||||
}
|
||||
|
||||
bulk_update_permissions(
|
||||
objects: Array<number>,
|
||||
permissions: { owner: number; set_permissions: PermissionsObject }
|
||||
): Observable<string> {
|
||||
return this.http.post<string>(`${this.baseUrl}bulk_edit_object_perms/`, {
|
||||
objects,
|
||||
object_type: this.resourceName,
|
||||
owner: permissions.owner,
|
||||
permissions: permissions.set_permissions,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue