Skip to content

Commit 6dd240a

Browse files
committed
show pdf upload form elements on demand
1 parent 204fd7d commit 6dd240a

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

packages/docs/en/docs/other/browser-example.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ The application is structured as a wizard.
9696
</small>
9797
</div>
9898
</div>
99-
<div class="form-group">
99+
<div class="form-group" id="embed-pdf-checkbox">
100100
<div class="form-check">
101101
<input class="form-check-input" type="checkbox" name="embed-pdf"
102102
id="embed-pdf">
103103
<label class="form-check-label" for="embedPDF">Embed PDF?</label>
104104
</div>
105105
</div>
106-
<div class="form-group">
107-
<label>Invoice PDF <span id="invoice-pdf-required">(*)</span></label>
106+
<div class="form-group" id="pdf-file-upload">
107+
<label>Invoice PDF (*)</label>
108108
<div class="custom-file">
109109
<input type="file" class="custom-file-input" id="pdf-file">
110110
<label class="custom-file-label" for="ppdf-file">
@@ -113,7 +113,7 @@ The application is structured as a wizard.
113113
<small class="form-text text-muted">For example
114114
<a href="https://github.com/gflohr/e-invoice-eu/blob/main/contrib/templates/default-invoice.pdf"
115115
target="_blank">
116-
default-invoice.yaml
116+
default-invoice.pdf
117117
</a>
118118
</small>
119119
</div>

packages/docs/site/js/browser-example.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,19 @@
2323
document.getElementById('json-file-upload').style.display = 'block';
2424
}
2525

26+
const showEmbedPDF = mimeType !== 'application/pdf';
27+
if (showEmbedPDF) {
28+
document.getElementById('embed-pdf-checkbox').style.display = 'block';
29+
} else {
30+
document.getElementById('embed-pdf-checkbox').style.display = 'none';
31+
}
32+
2633
const embedPDF = document.getElementById('embed-pdf').checked;
27-
const needPDF = mimeType === 'application/pdf' || embedPDF;
34+
const needPDF = mimeType === 'application/pdf' || (embedPDF && showEmbedPDF);
2835
if (needPDF) {
29-
document.getElementById('invoice-pdf-required').style.display = 'inline';
30-
document.getElementById('pdf-file').setAttribute('required', 'required');
36+
document.getElementById('pdf-file-upload').style.display = 'block';
3137
} else {
32-
document.getElementById('invoice-pdf-required').style.display = 'none';
33-
document.getElementById('pdf-file').removeAttribute('required');
38+
document.getElementById('pdf-file-upload').style.display = 'none';
3439
}
3540
}
3641

0 commit comments

Comments
 (0)