From ac33e6302e184936dcd01642ffa16d29db204915 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 15 May 2017 17:39:33 -0300 Subject: [PATCH] Fix addExistingPurchase + few other bugs --- kfet/static/kfet/js/kpsul.js | 13 +++++++++++-- kfet/templates/kfet/kpsul.html | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/kfet/static/kfet/js/kpsul.js b/kfet/static/kfet/js/kpsul.js index 5645263d..e6fbd0c9 100644 --- a/kfet/static/kfet/js/kpsul.js +++ b/kfet/static/kfet/js/kpsul.js @@ -519,18 +519,26 @@ class ArticleManager { that.reset(); that.focus(); } - if (normalKeys.test(e.keyCode) || arrowKeys.test(e.KeyCode) || e.ctrlKey) { + + if (normalKeys.test(e.keyCode) || arrowKeys.test(e.keyCode) || e.ctrlKey) { if (e.ctrlKey && e.charCode == 65) that._$nb.val(''); return true ; } + if (that.constructor.check_nb(that.nb+e.key)) return true; + return false; }); } + //Note : this function may not be needed after the whole rework + get_article(id) { + return this.data.find('article', id) ; + } + focus() { if (this.is_empty()) this._$input.focus(); @@ -561,11 +569,12 @@ class ArticleAutocomplete { // 8:Backspace|9:Tab|13:Enter|46:DEL|112-117:F1-6|119-123:F8-F12 var normalKeys = /^(8|9|13|46|112|113|114|115|116|117|119|120|121|122|123)$/; + var arrowKeys = /^(37|38|39|40)$/; this._$input .on('keydown', function(e) { var text = that._$input.val() ; - if (normalKeys.test(e.keyCode) || e.ctrlKey) { + if (normalKeys.test(e.keyCode) || arrowKeys.test(e.keyCode) || e.ctrlKey) { // For the backspace key, we suppose the cursor is at the very end if(e.keyCode == 8) { that.update(text.substring(0, text.length-1), true); diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index 16119bce..e94f5c6c 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -266,7 +266,7 @@ $(document).ready(function() { var article_basket_html = $(item_basket_default_html); article_basket_html .attr('data-opeindex', index) - .find('.number').text(nb).end() + .find('.number').text('('+nb+'/'+article.stock+')').end() .find('.name').text(article.name).end() .find('.amount').text(amountToUKF(amount_euro, kpsul.account_manager.account.is_cof)); basket_container.prepend(article_basket_html);