ScanButton (Barcode/NFC)
This form control (button) starts a scan of barcodes and processes the decoded information inside the form. The control is based on the NPM cross-platform barcode scanner for cordova and ZXing barcode scanner for browser.
<div id="scanBtn"
class="pdf-hide"
data-win-control="HFWinJSCtrl.ScanButton"
data-win-options="{
buttonType: 'large',
icon: 'fa-barcode-scan',
buttonHeading: 'QR-Code',
buttonLabel: 'Scan',
scan: {
fieldId: 'add_parts_item1',
scanType: 'BARCODE',
config: {
preferFrontCamera : false,
showFlipCameraButton : true,
showTorchButton : true,
saveHistory: false,
prompt : 'Please scan the appropriate barcode...',
resultDisplayDuration: 500,
formats : 'QR_CODE,AZTEC',
disableAnimations : true,
disableSuccessBeep: false
},
audioFeedback: true,
vibrationFeedback: true,
callbackFeedback: true,
callback: HFFormdefinition.BaseHelpers.customQRScanButton
}
}">
</div>
<div id="nfcScanBtn" class="hide-in-view"
data-win-control="HFWinJSCtrl.ScanButton"
data-win-options="{
buttonType: 'large',
buttonHeading: 'NFC-Code',
buttonLabel: 'Scan',
buttonIcon: 'fa-times',
scan: {
mapping: {
'0': 'nfc-textfield-1',
'1': 'nfc-textfield-2',
'2': 'nfc-textfield-3'
},
scanType: 'NFC',
postProcess: HFFormdefinition.BaseHelpers.postProcessNFC
}
}">
</div>
FormControl Options
buttonType - required
Define the size of the button ('small', 'medium' or 'large').
buttonType: 'large'
'small' | 'medium' | 'large'
fieldId - required
Provide the ID of the form control receiving the scanned value.
fieldId: 'add_parts_item1'
string
buttonHeading
Define a label for the control element.
buttonHeading: 'Navigation'
string
buttonLabel
Sets the label of the button (displayed if buttonType is "medium" or "large")
buttonLabel: 'Scan'
string
scan
An object with key-value pairs defining the form field and the scan type, a config part for the plugin and an optional custom postprocessing function
scan: { ... }
ScanObject
Scan Object
scanType - required
Defines the used scanning type.
scanType: 'BARCODE'
'BARCODE' | 'NFC'
audioFeedback
Enables or disables an audible feedback on proccessing the scan.
audioFeedback: true
boolean
true
callback
Call a custom JS-method after the scan is completed
callback: HFFormdefinition.BaselHelpers.callback
function
function(config: any, result: any, postfix: string) => void
callbackFeedback
Enables or disables a audible feedback on success.
callbackFeedback: true
boolean
true
config
Configuration object for scan type BARCODE. For more information check out the links below.
config: { ... }
object
errorMessage
Customized error message in case the scan fails.
errorMessage: 'This is my custom error.'
string
fieldId
FormControl in which the scan value is entered.
fieldId: 'scan_input_id'
string
mapping
An object with key-value pairs defining the scan record id and form field ID (especially for NFC Ndef Messages). Overwrites fieldId if both are set!
mapping: { '0': 'scan_input_id_1', '1': 'scan_input_id_1' }
{ [scanKey: string]: string }
multiple
Enables or disables multiple scanning. Scan starts again after successful scan. It is aborted after an error or by cancel scanning manually.
multiple: true
boolean
multipleMessage
Displays confirm message after every scan to start or abort next scan.
multipleMessage: 'Another scan follows - abort with Cancel or Back'
string
postProcess
Call a custom JS-method to postprocess the scanned values
postProcess: HFFormdefinition.BaselHelpers.postProcessMRZ
function
function(config: any, result: any, postfix: string) => Promise<any>
vibrationFeedback
Enables or disables a haptic feedback on proccessing the scan.
vibrationFeedback: true
boolean
true
For further information on the config values especially the formats for Barcode/QR-Code scanning (formats : 'QR_CODE,AZTEC'
), please read the documentation at https://github.com/phonegap/phonegap-plugin-barcodescanner for mobile scanning and at https://www.npmjs.com/package/@zxing/library for browser scanning.