mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-14 00:09:35 -06:00
Make content edits target a specific version
This commit is contained in:
@@ -740,6 +740,18 @@ describe('DocumentDetailComponent', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('save should target currently selected version', () => {
|
||||
initNormally()
|
||||
component.selectedVersionId = 10
|
||||
const patchSpy = jest.spyOn(documentService, 'patch')
|
||||
patchSpy.mockReturnValue(of(doc))
|
||||
|
||||
component.save()
|
||||
|
||||
expect(patchSpy).toHaveBeenCalled()
|
||||
expect(patchSpy.mock.calls[0][1]).toEqual(10)
|
||||
})
|
||||
|
||||
it('should show toast error on save if error occurs', () => {
|
||||
currentUserHasObjectPermissions = true
|
||||
initNormally()
|
||||
|
||||
@@ -1079,7 +1079,7 @@ export class DocumentDetailComponent
|
||||
this.networkActive = true
|
||||
;(document.activeElement as HTMLElement)?.dispatchEvent(new Event('change'))
|
||||
this.documentsService
|
||||
.patch(this.getChangedFields())
|
||||
.patch(this.getChangedFields(), this.selectedVersionId)
|
||||
.pipe(first())
|
||||
.subscribe({
|
||||
next: (docValues) => {
|
||||
@@ -1134,7 +1134,7 @@ export class DocumentDetailComponent
|
||||
this.networkActive = true
|
||||
this.store.next(this.documentForm.value)
|
||||
this.documentsService
|
||||
.patch(this.getChangedFields())
|
||||
.patch(this.getChangedFields(), this.selectedVersionId)
|
||||
.pipe(
|
||||
switchMap((updateResult) => {
|
||||
this.savedViewService.maybeRefreshDocumentCounts()
|
||||
|
||||
@@ -298,6 +298,14 @@ describe(`DocumentService`, () => {
|
||||
expect(req.request.body.remove_inbox_tags).toEqual(true)
|
||||
})
|
||||
|
||||
it('should pass selected version to patch when provided', () => {
|
||||
subscription = service.patch(documents[0], 123).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/?version=123`
|
||||
)
|
||||
expect(req.request.method).toEqual('PATCH')
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for getting audit log', () => {
|
||||
subscription = service.getHistory(documents[0].id).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
|
||||
@@ -227,11 +227,14 @@ export class DocumentService extends AbstractPaperlessService<Document> {
|
||||
return this.http.get<number>(this.getResourceUrl(null, 'next_asn'))
|
||||
}
|
||||
|
||||
patch(o: Document): Observable<Document> {
|
||||
patch(o: Document, versionID: number = null): Observable<Document> {
|
||||
o.remove_inbox_tags = !!this.settingsService.get(
|
||||
SETTINGS_KEYS.DOCUMENT_EDITING_REMOVE_INBOX_TAGS
|
||||
)
|
||||
return super.patch(o)
|
||||
this.clearCache()
|
||||
return this.http.patch<Document>(this.getResourceUrl(o.id), o, {
|
||||
params: versionID ? { version: versionID.toString() } : {},
|
||||
})
|
||||
}
|
||||
|
||||
uploadDocument(formData) {
|
||||
|
||||
Reference in New Issue
Block a user