Added 'Merge into single PDF' checkbox to the download form

This commit is contained in:
Łukasz Czyż 2023-12-11 19:56:19 +01:00
parent a3d6967192
commit 64bc64b630
2 changed files with 39 additions and 2 deletions

View File

@ -126,6 +126,12 @@
Use formatted filename
</label>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="downloadAsSingleFile" formControlName="downloadAsSingleFile" />
<label class="form-check-label" for="downloadAsSingleFile" i18n>
Merge into single PDF
</label>
</div>
</form>
</div>
</div>

View File

@ -65,6 +65,7 @@ export class BulkEditorComponent
downloadFileTypeArchive: new FormControl(true),
downloadFileTypeOriginals: new FormControl(false),
downloadUseFormatting: new FormControl(false),
downloadAsSingleFile: new FormControl(false),
})
constructor(
@ -136,7 +137,11 @@ export class BulkEditorComponent
.get('downloadFileTypeArchive')
.valueChanges.pipe(takeUntil(this.unsubscribeNotifier))
.subscribe((newValue) => {
if (!newValue) {
if (newValue && this.downloadForm.get('downloadAsSingleFile').value) {
this.downloadForm
.get('downloadFileTypeOriginals')
.patchValue(false, { emitEvent: false })
} else if (!newValue) {
this.downloadForm
.get('downloadFileTypeOriginals')
.patchValue(true, { emitEvent: false })
@ -146,12 +151,38 @@ export class BulkEditorComponent
.get('downloadFileTypeOriginals')
.valueChanges.pipe(takeUntil(this.unsubscribeNotifier))
.subscribe((newValue) => {
if (!newValue) {
if (newValue && this.downloadForm.get('downloadAsSingleFile').value) {
this.downloadForm
.get('downloadFileTypeArchive')
.patchValue(false, { emitEvent: false })
} else if (!newValue) {
this.downloadForm
.get('downloadFileTypeArchive')
.patchValue(true, { emitEvent: false })
}
})
this.downloadForm
.get('downloadAsSingleFile')
.valueChanges.pipe(takeUntil(this.unsubscribeNotifier))
.subscribe((newValue) => {
if (newValue) {
this.downloadForm
.get('downloadUseFormatting')
.patchValue(false, { emitEvent: false })
this.downloadForm.get('downloadUseFormatting').disable()
if (
this.downloadForm.get('downloadFileTypeArchive').value &&
this.downloadForm.get('downloadFileTypeOriginals').value
) {
this.downloadForm
.get('downloadFileTypeArchive')
.patchValue(false, { emitEvent: false })
}
} else {
this.downloadForm.get('downloadUseFormatting').enable()
}
})
}
ngOnDestroy(): void {