Skip to content

Commit 6e9f8fe

Browse files
committed
Fix feedback from PR
1 parent 706347b commit 6e9f8fe

4 files changed

Lines changed: 37 additions & 11 deletions

File tree

backend/zgw/documenten-api-preview/src/main/kotlin/com/ritense/documentenapipreview/client/PdfConversionClient.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ class PdfConversionClient(
4646
val bodyBuilder = MultipartBodyBuilder().apply {
4747
part("files", InputStreamResource(document)).filename(fileName ?: "file_name_unknown")
4848
part("exportFormFields", "false")
49-
part("pdfa", convertPdfArchiveMethodToGotenbergValue(pdfArchiveMethod))
49+
if (pdfArchiveMethod != PdfArchiveMethod.NONE) {
50+
part("pdfa", convertPdfArchiveMethodToGotenbergValue(pdfArchiveMethod))
51+
}
5052
if (pdfUniversalAccessibility) {
5153
part("pdfua", "true")
5254
} else {

backend/zgw/documenten-api-preview/src/main/kotlin/com/ritense/documentenapipreview/domain/PdfArchiveMethod.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2015-2024 Ritense BV, the Netherlands.
3+
*
4+
* Licensed under EUPL, Version 1.2 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" basis,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.ritense.documentenapipreview.domain
218

319
import com.fasterxml.jackson.annotation.JsonProperty

backend/zgw/documenten-api-preview/src/test/kotlin/com/ritense/documentenapipreview/client/PdfConversionClientIT.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.ritense.documentenapipreview.client
1919
import com.fasterxml.jackson.databind.ObjectMapper
2020
import com.ritense.documentenapipreview.BaseIntegrationTest
2121
import com.ritense.documentenapipreview.DocumentenApiPreviewPlugin
22+
import com.ritense.documentenapipreview.domain.PdfArchiveMethod
2223
import okhttp3.mockwebserver.Dispatcher
2324
import okhttp3.mockwebserver.MockResponse
2425

@@ -67,7 +68,9 @@ internal class PdfConversionClientIT @Autowired constructor(
6768
val stream = pdfConversionClient.convertDocument(
6869
documentenApiPreviewPlugin.pdfConversionUrl,
6970
"test_document".byteInputStream(),
70-
"dummy_file.txt"
71+
"dummy_file.txt",
72+
PdfArchiveMethod.PDFA2B,
73+
true
7174
)
7275

7376
assertNotNull(stream)

frontend/projects/valtimo/plugin/src/lib/plugins/documenten-api-preview/components/documenten-api-preview-configuration/documenten-api-preview-configuration.component.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core';
1818
import {PluginConfigurationComponent} from '../../../../models';
19-
import {BehaviorSubject, combineLatest, map, Observable, Subscription, take} from 'rxjs';
19+
import {BehaviorSubject, combineLatest, map, Observable, skip, Subscription, take} from 'rxjs';
2020
import {DocumentenApiPreviewConfig} from '../../models';
2121
import {PluginManagementService, PluginTranslationService} from '../../../../services';
2222
import {TranslateService} from '@ngx-translate/core';
@@ -46,9 +46,9 @@ export class DocumentenApiPreviewConfigurationComponent
4646

4747
public readonly pdfArchiveMethods: SelectItem[] = [
4848
{id: 'none', text: 'None', translationKey: 'pdfArchiveMethodNone'},
49-
{id: 'PDF/A-1b', text: 'PDF/A-1b', translationKey: 'pdfArchiveMethodPDFA1b'},
50-
{id: 'PDF/A-2b', text: 'PDF/A-2b', translationKey: 'pdfArchiveMethodPDFA2b'},
51-
{id: 'PDF/A-3b', text: 'PDF/A-3b', translationKey: 'pdfArchiveMethodPDFA3b'},
49+
{id: 'PDF/A-1b', text: 'PDF/A-1b', translationKey: 'pdfArchiveMethodPdfA1b'},
50+
{id: 'PDF/A-2b', text: 'PDF/A-2b', translationKey: 'pdfArchiveMethodPdfA2b'},
51+
{id: 'PDF/A-3b', text: 'PDF/A-3b', translationKey: 'pdfArchiveMethodPdfA3b'},
5252
];
5353

5454
public readonly pdfUniversalAccessibility$ = new BehaviorSubject<boolean>(false);
@@ -100,15 +100,20 @@ export class DocumentenApiPreviewConfigurationComponent
100100
}
101101

102102
private initPdfUniversalAccessibilityEnabled(): void {
103-
this.prefillConfiguration$.pipe(take(1)).subscribe(configuration => {
104-
this.pdfUniversalAccessibility$.next(configuration.pdfArchiveUniversalAccessibility);
103+
this.prefillConfiguration$?.pipe(take(1)).subscribe(configuration => {
104+
this.pdfUniversalAccessibility$.next(!!configuration?.pdfUniversalAccessibility);
105105
});
106106
}
107107

108108
private openPdfUniversalAccessibilitySubscription(): void {
109-
this._pdfUniversalAccessibilitySubscription = this.pdfUniversalAccessibility$.subscribe(value => {
110-
this.formValueChange(this.formValue$.getValue())
111-
});
109+
this._pdfUniversalAccessibilitySubscription = this.pdfUniversalAccessibility$
110+
.pipe(skip(1))
111+
.subscribe(() => {
112+
const currentFormValue = this.formValue$.getValue();
113+
if (currentFormValue) {
114+
this.formValueChange(currentFormValue);
115+
}
116+
});
112117
}
113118

114119
private handleValid(formValue: DocumentenApiPreviewConfig): void {

0 commit comments

Comments
 (0)