From 38d623bcf919910fc47e3a77b8d664e95f6acf76 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 24 May 2017 00:16:45 -0500 Subject: [PATCH] Fix behavior of mobile receiving when first entering a quantity i.e. replace default of '1' if user first presses a numeric key, but always append to quantity after that --- tailbone/static/js/tailbone.mobile.js | 18 ++++++++++++++++-- .../templates/mobile/receiving/view_row.mako | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tailbone/static/js/tailbone.mobile.js b/tailbone/static/js/tailbone.mobile.js index 6f94c2f6..0926a42e 100644 --- a/tailbone/static/js/tailbone.mobile.js +++ b/tailbone/static/js/tailbone.mobile.js @@ -111,23 +111,37 @@ $(document).on('click', '#receiving-quantity-keypad-thingy .keypad-button', func var quantity = $('.receiving-quantity'); var value = quantity.text(); var key = $(this).text(); + var changed = $('#receiving-quantity-keypad-thingy').data('changed'); if (key == 'Del') { if (value.length == 1) { quantity.text('0'); } else { quantity.text(value.substring(0, value.length - 1)); } + changed = true; } else if (key == '.') { if (value.indexOf('.') == -1) { - quantity.text(value + '.'); + if (changed) { + quantity.text(value + '.'); + } else { + quantity.text('0.'); + changed = true; + } } } else { if (value == '0') { quantity.text(key); - } else { + changed = true; + } else if (changed) { quantity.text(value + key); + } else { + quantity.text(key); + changed = true; } } + if (changed) { + $('#receiving-quantity-keypad-thingy').data('changed', true); + } }); diff --git a/tailbone/templates/mobile/receiving/view_row.mako b/tailbone/templates/mobile/receiving/view_row.mako index dd7440c5..75750726 100644 --- a/tailbone/templates/mobile/receiving/view_row.mako +++ b/tailbone/templates/mobile/receiving/view_row.mako @@ -38,7 +38,7 @@ - +
${h.link_to("7", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}