From ab87a950e522bed10ca85951cae8bf89e483b7fa Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Fri, 4 Nov 2022 11:21:39 +0530 Subject: [PATCH] fix: conflicts --- erpnext/public/js/utils/barcode_scanner.js | 37 +++++++++------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/erpnext/public/js/utils/barcode_scanner.js b/erpnext/public/js/utils/barcode_scanner.js index 695c0b9f5b1..1d34edef7af 100644 --- a/erpnext/public/js/utils/barcode_scanner.js +++ b/erpnext/public/js/utils/barcode_scanner.js @@ -21,6 +21,11 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { this.items_table_name = opts.items_table_name || "items"; this.items_table = this.frm.doc[this.items_table_name]; + // optional sound name to play when scan either fails or passes. + // see https://frappeframework.com/docs/v14/user/en/python-api/hooks#sounds + this.success_sound = opts.play_success_sound; + this.fail_sound = opts.play_fail_sound; + // any API that takes `search_value` as input and returns dictionary as follows // { // item_code: "HORSESHOE", // present if any item was found @@ -42,27 +47,6 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { return; } -<<<<<<< HEAD - frappe - .call({ - method: this.scan_api, - args: { - search_value: input, - }, - }) - .then((r) => { - const data = r && r.message; - if (!data || Object.keys(data).length === 0) { - this.show_alert(__("Cannot find Item with this Barcode"), "red"); - this.clean_up(); - reject(); - return; - } - - me.update_table(data).then(row => { - row ? resolve(row) : reject(); - }); -======= this.scan_api_call(input, (r) => { const data = r && r.message; if (!data || Object.keys(data).length === 0) { @@ -79,7 +63,6 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { }).catch(() => { this.play_fail_sound(); reject(); ->>>>>>> e1f9ba78e5 (fix: Scan Barcode UX) }); }); }); @@ -111,6 +94,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { if (this.dont_allow_new_row) { this.show_alert(__("Maximum quantity scanned for item {0}.", [item_code]), "red"); this.clean_up(); + reject(); return; } this.is_new_row = true; @@ -124,6 +108,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { if (this.is_duplicate_serial_no(row, serial_no)) { this.clean_up(); + reject(); return; } @@ -430,6 +415,14 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { get_existing_blank_row() { return this.items_table.find((d) => !d.item_code); } + + play_success_sound() { + this.success_sound && frappe.utils.play_sound(this.success_sound); + } + + play_fail_sound() { + this.fail_sound && frappe.utils.play_sound(this.fail_sound); + } clean_up() { this.scan_barcode_field.set_value("");