diff --git a/erpnext/selling/page/point_of_sale/pos_item_selector.js b/erpnext/selling/page/point_of_sale/pos_item_selector.js index e930322a2c4..961057e3baa 100644 --- a/erpnext/selling/page/point_of_sale/pos_item_selector.js +++ b/erpnext/selling/page/point_of_sale/pos_item_selector.js @@ -79,10 +79,48 @@ erpnext.PointOfSale.ItemSelector = class { }); } +<<<<<<< HEAD +======= + set_items_not_found_banner() { + this.$items_container.removeClass(this.item_display_class); + this.$items_container.addClass("items-not-found"); + this.$items_container.html(__("Items not found.")); + } + + render_item_list_column_header() { + return `
+
${__("Name")}
+
${__("Price")}
+
${__("UOM")}
+
${__("Quantity Available")}
+
`; + } + +>>>>>>> 24b28b4d29 (fix(pos): escape item data on pos item selector (#55503)) get_item_html(item) { const me = this; // eslint-disable-next-line no-unused-vars - const { item_image, serial_no, batch_no, barcode, actual_qty, uom, price_list_rate } = item; + function sanitize_item_data(item) { + return Object.fromEntries( + Object.entries(item).map(([key, value]) => [ + key, + typeof value === "string" ? frappe.utils.escape_html(value) : value, + ]) + ); + } + const sanitize_item = sanitize_item_data(item); + const { + item_code, + stock_uom, + item_name, + item_image, + serial_no, + batch_no, + barcode, + actual_qty, + uom, + price_list_rate, + } = sanitize_item; const precision = flt(price_list_rate, 2) % 1 != 0 ? 2 : 0; let indicator_color; let qty_to_display = actual_qty; @@ -107,30 +145,39 @@ erpnext.PointOfSale.ItemSelector = class {
${frappe.get_abbr(item.item_name)}>>>>>> 24b28b4d29 (fix(pos): escape item data on pos item selector (#55503)) >
`; } else { return `
${qty_to_display}
-
${frappe.get_abbr(item.item_name)}
`; +
${frappe.get_abbr(item_name)}
`; } } return `
+ data-item-code="${item_code}" data-serial-no="${serial_no}" + data-batch-no="${batch_no}" data-uom="${uom}" + data-rate="${price_list_rate || 0}" + data-stock-uom="${stock_uom}" + title="${item_name}"> ${get_item_image_html()}
+<<<<<<< HEAD ${frappe.ellipsis(item.item_name, 18)} +======= + ${!me.hide_images ? frappe.ellipsis(item_name, 18) : item_name} +>>>>>>> 24b28b4d29 (fix(pos): escape item data on pos item selector (#55503))
${format_currency(price_list_rate, item.currency, precision) || 0} / ${uom}
@@ -138,7 +185,7 @@ erpnext.PointOfSale.ItemSelector = class { } handle_broken_image($img) { - const item_abbr = $($img).attr("alt"); + const item_abbr = frappe.utils.escape_html($($img).attr("alt")); $($img).parent().replaceWith(`
${item_abbr}
`); } @@ -186,6 +233,19 @@ erpnext.PointOfSale.ItemSelector = class { this.attach_clear_btn(); } +<<<<<<< HEAD +======= + set_item_selector_filter_label(value) { + const $filter_label = this.$component.find(".label"); + + $filter_label.html(value ? frappe.utils.escape_html(__(value)) : __("All Items")); + } + + hide_open_link_btn() { + $(this.item_group_field.$wrapper.find(".btn-open")).css("display", "none"); + } + +>>>>>>> 24b28b4d29 (fix(pos): escape item data on pos item selector (#55503)) attach_clear_btn() { this.search_field.$wrapper.find(".control-input").append( ` @@ -252,12 +312,12 @@ erpnext.PointOfSale.ItemSelector = class { this.$component.on("click", ".item-wrapper", function () { const $item = $(this); - const item_code = unescape($item.attr("data-item-code")); - let batch_no = unescape($item.attr("data-batch-no")); - let serial_no = unescape($item.attr("data-serial-no")); - let uom = unescape($item.attr("data-uom")); - let rate = unescape($item.attr("data-rate")); - let stock_uom = unescape($item.attr("data-stock-uom")); + const item_code = $item.attr("data-item-code"); + let batch_no = $item.attr("data-batch-no"); + let serial_no = $item.attr("data-serial-no"); + let uom = $item.attr("data-uom"); + let rate = $item.attr("data-rate"); + let stock_uom = $item.attr("data-stock-uom"); // escape(undefined) returns "undefined" then unescape returns "undefined" batch_no = batch_no === "undefined" ? undefined : batch_no;