Fix addExistingPurchase + few other bugs

This commit is contained in:
Ludovic Stephan 2017-05-15 17:39:33 -03:00
parent ad42687293
commit ac33e6302e
2 changed files with 12 additions and 3 deletions

View file

@ -519,18 +519,26 @@ class ArticleManager {
that.reset(); that.reset();
that.focus(); 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) if (e.ctrlKey && e.charCode == 65)
that._$nb.val(''); that._$nb.val('');
return true ; return true ;
} }
if (that.constructor.check_nb(that.nb+e.key)) if (that.constructor.check_nb(that.nb+e.key))
return true; return true;
return false; return false;
}); });
} }
//Note : this function may not be needed after the whole rework
get_article(id) {
return this.data.find('article', id) ;
}
focus() { focus() {
if (this.is_empty()) if (this.is_empty())
this._$input.focus(); 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 // 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 normalKeys = /^(8|9|13|46|112|113|114|115|116|117|119|120|121|122|123)$/;
var arrowKeys = /^(37|38|39|40)$/;
this._$input this._$input
.on('keydown', function(e) { .on('keydown', function(e) {
var text = that._$input.val() ; 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 // For the backspace key, we suppose the cursor is at the very end
if(e.keyCode == 8) { if(e.keyCode == 8) {
that.update(text.substring(0, text.length-1), true); that.update(text.substring(0, text.length-1), true);

View file

@ -266,7 +266,7 @@ $(document).ready(function() {
var article_basket_html = $(item_basket_default_html); var article_basket_html = $(item_basket_default_html);
article_basket_html article_basket_html
.attr('data-opeindex', index) .attr('data-opeindex', index)
.find('.number').text(nb).end() .find('.number').text('('+nb+'/'+article.stock+')').end()
.find('.name').text(article.name).end() .find('.name').text(article.name).end()
.find('.amount').text(amountToUKF(amount_euro, kpsul.account_manager.account.is_cof)); .find('.amount').text(amountToUKF(amount_euro, kpsul.account_manager.account.is_cof));
basket_container.prepend(article_basket_html); basket_container.prepend(article_basket_html);