From 3c693dd88a0df9b6a90acf01b89c7ecb2b324840 Mon Sep 17 00:00:00 2001 From: Corentin Forler <8860073-cforler_dokos@users.noreply.gitlab.com> Date: Fri, 15 Dec 2023 17:53:16 +0100 Subject: [PATCH 1/5] fix(pos): Fix selected item highlighting --- .../selling/page/point_of_sale/pos_item_cart.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/erpnext/selling/page/point_of_sale/pos_item_cart.js b/erpnext/selling/page/point_of_sale/pos_item_cart.js index d806c628ff5..a446b74c69e 100644 --- a/erpnext/selling/page/point_of_sale/pos_item_cart.js +++ b/erpnext/selling/page/point_of_sale/pos_item_cart.js @@ -279,16 +279,21 @@ erpnext.PointOfSale.ItemCart = class { } toggle_item_highlight(item) { + // @dokos const $cart_item = $(item); - const item_is_highlighted = $cart_item.attr("style") == "background-color:var(--gray-50);"; - + const item_is_highlighted = !this.$numpad_section.is(":visible"); + this.$cart_container.find(".cart-item-wrapper").css({ + "background-color": "", + "box-shadow": "", + }); if (!item || item_is_highlighted) { this.item_is_selected = false; - this.$cart_container.find('.cart-item-wrapper').css("background-color", ""); } else { - $cart_item.css("background-color", "var(--control-bg)"); this.item_is_selected = true; - this.$cart_container.find('.cart-item-wrapper').not(item).css("background-color", ""); + $cart_item.css({ + "background-color": "var(--alert-bg-info)", + "box-shadow": "inset 0px 0px 0px 2px var(--alert-text-info)", + }); } } @@ -803,6 +808,7 @@ erpnext.PointOfSale.ItemCart = class { } else { this.$totals_section.css('display', 'flex'); this.$numpad_section.css('display', 'none'); + this.toggle_item_highlight(); } this.reset_numpad(); } -- GitLab From 7d3ae8c639c338c12d7f6865ec00e26b48672473 Mon Sep 17 00:00:00 2001 From: Corentin Forler <8860073-cforler_dokos@users.noreply.gitlab.com> Date: Fri, 15 Dec 2023 17:55:24 +0100 Subject: [PATCH 2/5] fix(pos): Ignore invalid item_stock_map --- erpnext/selling/page/point_of_sale/pos_item_details.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/selling/page/point_of_sale/pos_item_details.js b/erpnext/selling/page/point_of_sale/pos_item_details.js index 453aff1395f..2fa6d4c4dad 100644 --- a/erpnext/selling/page/point_of_sale/pos_item_details.js +++ b/erpnext/selling/page/point_of_sale/pos_item_details.js @@ -236,8 +236,9 @@ erpnext.PointOfSale.ItemDetails = class { if (this.value) { me.events.form_updated(me.current_item, 'warehouse', this.value).then(() => { me.item_stock_map = me.events.get_item_stock_map(); - const available_qty = me.item_stock_map[me.item_row.item_code][this.value][0]; - const is_stock_item = Boolean(me.item_stock_map[me.item_row.item_code][this.value][1]); + const stock_map = me.item_stock_map[me.item_row.item_code][this.value]; + const available_qty = stock_map?.[0]; + const is_stock_item = Boolean(stock_map?.[1]); if (available_qty === undefined) { me.events.get_available_stock(me.item_row.item_code, this.value).then(() => { // item stock map is updated now reset warehouse -- GitLab From 9752732a57752acd97a4cfe26928a6ad26f3fc29 Mon Sep 17 00:00:00 2001 From: Corentin Forler <8860073-cforler_dokos@users.noreply.gitlab.com> Date: Fri, 15 Dec 2023 17:55:51 +0100 Subject: [PATCH 3/5] fix(pos): Fix render_item_list when list is null --- erpnext/selling/page/point_of_sale/pos_item_selector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c5523338297..e4c006d20c5 100644 --- a/erpnext/selling/page/point_of_sale/pos_item_selector.js +++ b/erpnext/selling/page/point_of_sale/pos_item_selector.js @@ -69,7 +69,7 @@ erpnext.PointOfSale.ItemSelector = class { render_item_list(items) { this.$items_container.html(''); - items.forEach(item => { + items?.forEach(item => { const item_html = this.get_item_html(item); this.$items_container.append(item_html); }); -- GitLab From 27aaab268e70b5894f49134765a6a6ca1fb57d6f Mon Sep 17 00:00:00 2001 From: Corentin Forler <8860073-cforler_dokos@users.noreply.gitlab.com> Date: Fri, 15 Dec 2023 18:20:46 +0100 Subject: [PATCH 4/5] feat(pos): Clear Item Group input on focus --- .../selling/page/point_of_sale/pos_item_selector.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 e4c006d20c5..3941d266382 100644 --- a/erpnext/selling/page/point_of_sale/pos_item_selector.js +++ b/erpnext/selling/page/point_of_sale/pos_item_selector.js @@ -147,6 +147,7 @@ erpnext.PointOfSale.ItemSelector = class { this.$component.find('.item-group-field').html(''); this.search_field = frappe.ui.form.make_control({ + only_input: true, df: { label: __('Search'), fieldtype: 'Data', @@ -156,12 +157,16 @@ erpnext.PointOfSale.ItemSelector = class { render_input: true, }); this.item_group_field = frappe.ui.form.make_control({ + only_input: true, + no_icon: true, df: { label: __('Item Group'), fieldtype: 'Link', options: 'Item Group', placeholder: __('Select item group'), onchange: function() { + this.$input?.blur?.(); + if (me.item_group === this.value) { return; } me.item_group = this.value; !me.item_group && (me.item_group = me.parent_item_group); me.filter_items(); @@ -182,6 +187,7 @@ erpnext.PointOfSale.ItemSelector = class { this.item_group_field.toggle_label(false); this.attach_clear_btn(); + this.bind_clear_group_on_focus(); } attach_clear_btn() { @@ -201,6 +207,13 @@ erpnext.PointOfSale.ItemSelector = class { }); } + bind_clear_group_on_focus() { + // @dokos + this.item_group_field.$wrapper.on("focusin", () => { + this.item_group_field.$input?.val?.("")?.trigger?.("input"); + }); + } + set_search_value(value) { $(this.search_field.$input[0]).val(value).trigger("input"); } -- GitLab From 5a9ddc7c214e8869e1edbe605022a76e65ac7a7e Mon Sep 17 00:00:00 2001 From: Corentin Forler <8860073-cforler_dokos@users.noreply.gitlab.com> Date: Fri, 15 Dec 2023 18:21:13 +0100 Subject: [PATCH 5/5] feat(pos): Add "Load More Items" button --- .../page/point_of_sale/pos_item_selector.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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 3941d266382..eff22e8a9c5 100644 --- a/erpnext/selling/page/point_of_sale/pos_item_selector.js +++ b/erpnext/selling/page/point_of_sale/pos_item_selector.js @@ -52,6 +52,7 @@ erpnext.PointOfSale.ItemSelector = class { } get_items({start = 0, page_length = 40, search_term=''}) { + if (this.page_length) { page_length = this.page_length; } const doc = this.events.get_frm().doc; const price_list = (doc && doc.selling_price_list) || this.price_list; let { item_group, pos_profile } = this; @@ -65,14 +66,28 @@ erpnext.PointOfSale.ItemSelector = class { }); } - - render_item_list(items) { - this.$items_container.html(''); + render_item_list(items, append = false) { + if (!append) { + this.$items_container.html(''); + } items?.forEach(item => { const item_html = this.get_item_html(item); this.$items_container.append(item_html); }); + + if (items?.length >= (this.page_length || 40)) { + // @dokos + const $load_more_btn = $('