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:
Faris Ansari 2019-09-16 15:20:10 +05:30 committed by Nabin Hait
parent 2818b5bbe7
commit 8beca68948

View File

@ -277,8 +277,30 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
this.set_dynamic_labels(); this.set_dynamic_labels();
this.setup_sms(); this.setup_sms();
this.setup_quality_inspection(); this.setup_quality_inspection();
this.frm.fields_dict["scan_barcode"] && this.frm.fields_dict["scan_barcode"].set_value(""); let scan_barcode_field = this.frm.get_field('scan_barcode');
this.frm.fields_dict["scan_barcode"] && this.frm.fields_dict["scan_barcode"].set_new_description(""); 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() { scan_barcode: function() {