Skip to content

Commit 3260651

Browse files
committed
fix(QrcodeDropZone): formats prop is not passed along
Closes #453
1 parent 35da4e0 commit 3260651

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

docs/.vitepress/components/demos/DragDrop.vue

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
<template>
22
<div>
3+
<p>
4+
By default only QR-codes are detected but a variety of other barcode formats are also
5+
supported. You can select one or multiple but the more you select the more expensive scanning
6+
becomes: <br />
7+
8+
<span
9+
v-for="option in Object.keys(barcodeFormats)"
10+
:key="option"
11+
class="barcode-format-checkbox"
12+
>
13+
<input
14+
type="checkbox"
15+
v-model="barcodeFormats[option]"
16+
:id="option"
17+
/>
18+
<label :for="option">{{ option }}</label>
19+
</span>
20+
</p>
21+
322
<p class="decode-result">
423
Last result: <b>{{ result }}</b>
524
</p>
@@ -15,6 +34,7 @@
1534
@detect="onDetect"
1635
@dragover="onDragOver"
1736
@error="logErrors"
37+
:formats="selectedBarcodeFormats"
1838
>
1939
<div
2040
class="drop-area"
@@ -29,17 +49,50 @@
2949
<script>
3050
import { QrcodeDropZone } from '../../../../src'
3151
52+
/*** barcode formats ***/
53+
3254
export default {
3355
components: { QrcodeDropZone },
3456
3557
data() {
3658
return {
3759
result: null,
3860
error: null,
39-
dragover: false
61+
dragover: false,
62+
barcodeFormats: {
63+
aztec: false,
64+
code_128: false,
65+
code_39: false,
66+
code_93: false,
67+
codabar: false,
68+
databar: false,
69+
databar_expanded: false,
70+
data_matrix: false,
71+
dx_film_edge: false,
72+
ean_13: false,
73+
ean_8: false,
74+
itf: false,
75+
maxi_code: false,
76+
micro_qr_code: false,
77+
pdf417: false,
78+
qr_code: true,
79+
rm_qr_code: false,
80+
upc_a: false,
81+
upc_e: false,
82+
linear_codes: false,
83+
matrix_codes: false
84+
}
4085
}
4186
},
4287
88+
computed: {
89+
selectedBarcodeFormats() {
90+
return Object
91+
.keys(this.barcodeFormats)
92+
.filter(format => this.barcodeFormats[format])
93+
}
94+
},
95+
4396
methods: {
4497
onDetect(detectedCodes) {
4598
console.log(detectedCodes)

src/components/QrcodeDropZone.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const onDrop = ({ dataTransfer }: DragEvent) => {
4646
const droppedUrl = dataTransfer.getData('text/uri-list')
4747
4848
droppedFiles.forEach((file: File) => {
49-
onDetect(processFile(file))
49+
onDetect(processFile(file, props.formats))
5050
})
5151
5252
if (droppedUrl !== '') {

0 commit comments

Comments
 (0)