From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Thu, 25 Jan 2024 21:22:03 +0000 (-0800)
Subject: Fix: tweak doc detail component behavior while awaiting metadata (#5546)
X-Git-Tag: v2.4.2~1^2~3
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fb4daf03e593706d123584398cd5e1e2f85bc66;p=thirdparty%2Fpaperless-ngx.git
Fix: tweak doc detail component behavior while awaiting metadata (#5546)
---
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html
index 038a44dbe3..a3890f961d 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.html
+++ b/src-ui/src/app/components/document-detail/document-detail.component.html
@@ -324,44 +324,45 @@
Loading...
- }
- @switch (contentRenderType) {
- @case (ContentRenderType.PDF) {
- @if (!useNativePdfViewer) {
-
-
-
+ } @else {
+ @switch (contentRenderType) {
+ @case (ContentRenderType.PDF) {
+ @if (!useNativePdfViewer) {
+
+ } @else {
+
+ }
+ }
+ @case (ContentRenderType.Text) {
+
{{previewText}}
+ }
+ @case (ContentRenderType.Image) {
+
+
- } @else {
+ }
+ @case (ContentRenderType.Other) {
}
}
- @case (ContentRenderType.Text) {
-
{{previewText}}
- }
- @case (ContentRenderType.Image) {
-
-
![{{title}}]()
+ @if (requiresPassword) {
+
+
}
- @case (ContentRenderType.Other) {
-
- }
- }
- @if (requiresPassword) {
-
-
-
}
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts
index cccf2677b4..af0e0e78e6 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts
+++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts
@@ -681,6 +681,7 @@ describe('DocumentDetailComponent', () => {
it('should support Enter key in password field', () => {
initNormally()
+ component.metadata = { has_archive_version: true }
component.onError({ name: 'PasswordException' }) // normally dispatched by pdf viewer
fixture.detectChanges()
expect(component.password).toBeUndefined()
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts
index 18e6b12117..0ce9fa0075 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.ts
+++ b/src-ui/src/app/components/document-detail/document-detail.component.ts
@@ -82,6 +82,7 @@ enum ContentRenderType {
Image = 'image',
Text = 'text',
Other = 'other',
+ Unknown = 'unknown',
}
enum ZoomSetting {
@@ -211,6 +212,7 @@ export class DocumentDetailComponent
}
get contentRenderType(): ContentRenderType {
+ if (!this.metadata) return ContentRenderType.Unknown
const contentType = this.metadata?.has_archive_version
? 'application/pdf'
: this.metadata?.original_mime_type