feat: Scan Barcode using Camera in mobile (#19033)
* feat: Scan Barcode using Camera in mobile * fix: Use input-group for scan button * fix: Muted camera button
This commit is contained in:
parent
2818b5bbe7
commit
8beca68948
@ -277,8 +277,30 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
this.set_dynamic_labels();
|
||||
this.setup_sms();
|
||||
this.setup_quality_inspection();
|
||||
this.frm.fields_dict["scan_barcode"] && this.frm.fields_dict["scan_barcode"].set_value("");
|
||||
this.frm.fields_dict["scan_barcode"] && this.frm.fields_dict["scan_barcode"].set_new_description("");
|
||||
let scan_barcode_field = this.frm.get_field('scan_barcode');
|
||||
if (scan_barcode_field) {
|
||||
scan_barcode_field.set_value("");
|
||||
scan_barcode_field.set_new_description("");
|
||||
|
||||
if (frappe.is_mobile()) {
|
||||
if (scan_barcode_field.$input_wrapper.find('.input-group').length) return;
|
||||
|
||||
let $input_group = $('<div class="input-group">');
|
||||
scan_barcode_field.$input_wrapper.find('.control-input').append($input_group);
|
||||
$input_group.append(scan_barcode_field.$input);
|
||||
$(`<span class="input-group-btn" style="vertical-align: top">
|
||||
<button class="btn btn-default border" type="button">
|
||||
<i class="fa fa-camera text-muted"></i>
|
||||
</button>
|
||||
</span>`)
|
||||
.on('click', '.btn', () => {
|
||||
frappe.barcode.scan_barcode().then(barcode => {
|
||||
scan_barcode_field.set_value(barcode);
|
||||
});
|
||||
})
|
||||
.appendTo($input_group);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
scan_barcode: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user