mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-14 00:09:35 -06:00
Fix UI content should change on version select and thumbnail
This commit is contained in:
@@ -1616,6 +1616,9 @@ describe('DocumentDetailComponent', () => {
|
||||
|
||||
previewSpy.mockReturnValueOnce('preview-version')
|
||||
jest.spyOn(documentService, 'getThumbUrl').mockReturnValue('thumb-version')
|
||||
jest
|
||||
.spyOn(documentService, 'get')
|
||||
.mockReturnValue(of({ content: 'version-content' } as Document))
|
||||
|
||||
component.selectVersion(10)
|
||||
httpTestingController.expectOne('preview-version').flush('version text')
|
||||
@@ -1623,6 +1626,7 @@ describe('DocumentDetailComponent', () => {
|
||||
expect(component.previewUrl).toBe('preview-version')
|
||||
expect(component.thumbUrl).toBe('thumb-version')
|
||||
expect(component.previewText).toBe('version text')
|
||||
expect(component.documentForm.get('content').value).toBe('version-content')
|
||||
const pdfSource = component.pdfSource as { url: string; password?: string }
|
||||
expect(pdfSource.url).toBe('preview-version')
|
||||
expect(pdfSource.password).toBeUndefined()
|
||||
|
||||
@@ -805,8 +805,38 @@ export class DocumentDetailComponent
|
||||
this.selectedVersionId
|
||||
)
|
||||
this.updatePdfSource()
|
||||
this.thumbUrl = this.documentsService.getThumbUrl(this.selectedVersionId)
|
||||
this.thumbUrl = this.documentsService.getThumbUrl(
|
||||
this.documentId,
|
||||
this.selectedVersionId
|
||||
)
|
||||
this.loadMetadataForSelectedVersion()
|
||||
this.documentsService
|
||||
.get(this.documentId, this.selectedVersionId, 'content')
|
||||
.pipe(
|
||||
first(),
|
||||
takeUntil(this.unsubscribeNotifier),
|
||||
takeUntil(this.docChangeNotifier)
|
||||
)
|
||||
.subscribe({
|
||||
next: (doc) => {
|
||||
const content = doc?.content ?? ''
|
||||
this.document.content = content
|
||||
this.documentForm.patchValue(
|
||||
{
|
||||
content,
|
||||
},
|
||||
{
|
||||
emitEvent: false,
|
||||
}
|
||||
)
|
||||
},
|
||||
error: (error) => {
|
||||
this.toastService.showError(
|
||||
$localize`Error retrieving version content`,
|
||||
error
|
||||
)
|
||||
},
|
||||
})
|
||||
// For text previews, refresh content
|
||||
this.http
|
||||
.get(this.previewUrl, { responseType: 'text' })
|
||||
|
||||
Reference in New Issue
Block a user