Skip to content

Commit

Permalink
Barcode decoder as user selection
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragchhatrala committed Dec 17, 2024
1 parent 551cf80 commit c45bbeb
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
5 changes: 5 additions & 0 deletions client/components/forms/BarcodeInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
>
<CameraUpload
:is-barcode-mode="true"
:decoders="decoders"
@stop-webcam="stopScanning"
@barcode-detected="handleBarcodeDetected"
/>
Expand Down Expand Up @@ -109,6 +110,10 @@ export default {
props: {
...inputProps,
decoders: {
type: Array,
default: () => []
}
},
setup(props, context) {
Expand Down
13 changes: 5 additions & 8 deletions client/components/forms/components/CameraUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export default {
type: Boolean,
default: false
},
decoders: {
type: Array,
default: () => []
}
},
emits: ['stopWebcam', 'uploadImage', 'barcodeDetected'],
data: () => ({
Expand Down Expand Up @@ -174,14 +178,7 @@ export default {
},
},
decoder: {
readers: [
"ean_reader",
"ean_8_reader",
"code_128_reader",
"code_39_reader",
"upc_reader",
"upc_e_reader"
]
readers: this.decoders || []
},
locate: true
}, (err) => {
Expand Down
4 changes: 4 additions & 0 deletions client/components/open/forms/OpenFormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ export default {
inputProperties.columns = field.columns
}
if (field.type === 'barcode') {
inputProperties.decoders = field.decoders
}
if (['select','multi_select'].includes(field.type) && !this.isFieldRequired) {
inputProperties.clearable = true
}
Expand Down
34 changes: 33 additions & 1 deletion client/components/open/forms/fields/components/FieldOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,27 @@
/>
</div>

<!-- Barcode Reader -->
<div
v-if="field.type === 'barcode'"
class="px-4"
>
<EditorSectionHeader
icon="i-material-symbols-barcode-scanner-rounded"
title="Barcode Reader"
/>
<select-input
name="decoders"
class="mt-4"
:form="field"
:options="barcodeDecodersOptions"
label="Decoders"
:searchable="true"
:multiple="true"
help="Select the decoders you want to use"
/>
</div>

<div
v-if="field.type === 'rating'"
class="px-4"
Expand Down Expand Up @@ -611,7 +632,15 @@ export default {
editorToolbarCustom: [
['bold', 'italic', 'underline', 'link']
],
allCountries: countryCodes
allCountries: countryCodes,
barcodeDecodersOptions: [
{ name: 'EAN-13', value: 'ean_reader' },
{ name: 'EAN-8', value: 'ean_8_reader' },
{ name: 'Code 128', value: 'code_128_reader' },
{ name: 'Code 39', value: 'code_39_reader' },
{ name: 'UPC-A', value: 'upc_reader' },
{ name: 'UPC-E', value: 'upc_e_reader' }
]
}
},
Expand Down Expand Up @@ -828,6 +857,9 @@ export default {
selection_data:{
'Row 1': null
}
},
barcode: {
decoders: this.barcodeDecodersOptions.map(decoder => decoder.value)
}
}
if (this.field.type in defaultFieldValues) {
Expand Down

0 comments on commit c45bbeb

Please sign in to comment.