diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index 71dd1bef998..c0b8c35388c 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -19,7 +19,7 @@ frappe.pages['pos'].refresh = function (wrapper) { erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ init: function (wrapper) { - this.page_len = 20; + this.page_len = 2; this.page = wrapper.page; this.wrapper = $(wrapper).find('.page-content'); this.set_indicator(); @@ -439,17 +439,52 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ // me.make_item_list(); // }); - this.wrapper.find(".btn-more").on("click", function() { - me.page_len += 20; + me.toggle_more_btn(); + + this.wrapper.on("click", ".btn-more", function() { + console.log('asdf') + me.page_len += 2; me.items = me.get_items(); me.make_item_list(); - }) + me.toggle_more_btn(); + }); - this.wrapper.find(".edit-customer-btn").on("click", function() { + this.page.wrapper.on("click", ".edit-customer-btn", function() { me.update_customer() }) }, + toggle_more_btn: function() { + if(!this.items || this.items.length <= this.page_len) { + this.wrapper.find(".btn-more").hide(); + } else { + this.wrapper.find(".btn-more").show(); + } + }, + + toggle_totals_area: function(show) { + + if(!show) { + show = this.is_totals_area_collapsed; + } + + var totals_area = this.wrapper.find('.totals-area'); + totals_area.find('.net-total-area, .tax-area, .discount-amount-area') + .toggle(show); + + if(show) { + totals_area.find('.collapse-btn i') + .removeClass('octicon-chevron-down') + .addClass('octicon-chevron-up'); + } else { + totals_area.find('.collapse-btn i') + .removeClass('octicon-chevron-up') + .addClass('octicon-chevron-down'); + } + + this.is_totals_area_collapsed = !show; + }, + make_list_customers: function () { var me = this; this.list_customers_btn = this.page.wrapper.find('.list-customers-btn'); @@ -458,6 +493,9 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.list_customers = this.wrapper.find('.list-customers'); this.numeric_keypad = this.wrapper.find('.numeric_keypad'); + me.render_list_customers(); + me.toggle_totals_area(false); + this.page.wrapper.on('click', '.list-customers-btn', function() { $(this).toggleClass("view_customer"); if($(this).hasClass("view_customer")) { @@ -472,7 +510,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ me.party_field.$input.attr('disabled', false); } me.pos_bill.show(); - me.list_customers.hide() + me.toggle_totals_area(false); + me.list_customers.hide(); if(me.frm.doc.items.length > 0) { me.numeric_keypad.show(); } @@ -484,6 +523,9 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ me.refresh(); me.set_focus(); }); + this.pos_bill.on('click', '.collapse-btn', function() { + me.toggle_totals_area(); + }); }, bind_numeric_keypad: function() { @@ -535,22 +577,17 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ var me = this; this.removed_items = []; - this.list_customers.empty(); + // this.list_customers.empty(); this.si_docs = this.get_doc_from_localstorage(); - if (!this.si_docs.length) { + if (!this.si_docs.length) {fv this.list_customers.append( '
' + html + '
') @@ -710,12 +743,16 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ customer.action.apply(me); return; } + me.toggle_list_customer(false); + me.toggle_edit_button(true); me.update_customer_data(customer); me.refresh(); me.set_focus(); }) .on('focus', function (e) { $(e.target).val('').trigger('input'); + me.toggle_edit_button(false); + me.toggle_list_customer(true); }) .on("awesomplete-selectcomplete", function (e) { var item = me.party_field.awesomeplete @@ -727,6 +764,14 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ }); }, + toggle_edit_button: function(flag) { + this.page.wrapper.find('.edit-customer-btn').toggle(flag); + }, + + toggle_list_customer: function(flag) { + this.list_customers.toggle(flag); + }, + add_customer: function() { this.frm.doc.customer = ""; this.update_customer() @@ -909,6 +954,26 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ })).tooltip().appendTo($wrap); } }); + + $wrap.append(` +" +__("Not items found")+"
").appendTo($wrap) @@ -1186,7 +1251,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.add_new_item_to_grid(); this.update_paid_amount_status(false) - this.wrapper.find(".item-cart").scrollTop(1000); + this.wrapper.find(".item-cart-items").scrollTop(1000); }, add_new_item_to_grid: function () { @@ -1317,7 +1382,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ me.refresh(); me.toggle_input_field(); me.set_focus(); - }) + }, "fa fa-plus") if (this.frm.doc.docstatus == 0) { // this.page.set_primary_action(__("Pay"), function () { // me.validate(); diff --git a/erpnext/public/css/erpnext.css b/erpnext/public/css/erpnext.css index bb1195a21c6..d92559e233e 100644 --- a/erpnext/public/css/erpnext.css +++ b/erpnext/public/css/erpnext.css @@ -295,12 +295,13 @@ body[data-route="pos"] .modal-dialog { margin-bottom: 15px; } .item-cart-items { - height: calc(100vh - 500px); + height: calc(100vh - 526px); overflow: auto; border: 1px solid #d1d8dd; border-top: none; } -.item-cart-items .no-items-message { +.pos .no-items-message { + min-height: 200px; display: flex; align-items: center; justify-content: center; @@ -316,14 +317,29 @@ body[data-route="pos"] .modal-dialog { overflow: hidden; } .pos .item-list { - border-left: 1px solid #d1d8dd; - border-right: 1px solid #d1d8dd; - height: calc(100vh - 180px); + border: 1px solid #d1d8dd; + border-top: none; + max-height: calc(100vh - 190px); overflow: auto; } +@media (max-width: 767px) { + .pos .item-list { + max-height: initial; + } +} .pos .item-list .image-field { height: 140px; } +.pos .item-list .pos-item-wrapper { + position: relative; +} +.pos .item-list .price-info { + position: absolute; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.1); + padding: 9px 15px; +} .pos-bill-toolbar { margin-top: 10px; } @@ -337,3 +353,17 @@ body[data-route="pos"] .modal-dialog { .pos-selected-item-action > .pos-list-row { border: none; } +.edit-customer-btn { + position: absolute; + right: 57px; + top: 15px; + z-index: 100; +} +.btn-more { + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; + background-color: #fafbfc; + min-height: 200px; +} diff --git a/erpnext/public/js/pos/customer_toolbar.html b/erpnext/public/js/pos/customer_toolbar.html index 86a38c3a8bf..a2cd834b543 100644 --- a/erpnext/public/js/pos/customer_toolbar.html +++ b/erpnext/public/js/pos/customer_toolbar.html @@ -1,5 +1,11 @@ -