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
This commit is contained in:
		
							parent
							
								
									5eca2347d5
								
							
						
					
					
						commit
						38d623bcf9
					
				
					 2 changed files with 17 additions and 3 deletions
				
			
		|  | @ -111,23 +111,37 @@ $(document).on('click', '#receiving-quantity-keypad-thingy .keypad-button', func | ||||||
|     var quantity = $('.receiving-quantity'); |     var quantity = $('.receiving-quantity'); | ||||||
|     var value = quantity.text(); |     var value = quantity.text(); | ||||||
|     var key = $(this).text(); |     var key = $(this).text(); | ||||||
|  |     var changed = $('#receiving-quantity-keypad-thingy').data('changed'); | ||||||
|     if (key == 'Del') { |     if (key == 'Del') { | ||||||
|         if (value.length == 1) { |         if (value.length == 1) { | ||||||
|             quantity.text('0'); |             quantity.text('0'); | ||||||
|         } else { |         } else { | ||||||
|             quantity.text(value.substring(0, value.length - 1)); |             quantity.text(value.substring(0, value.length - 1)); | ||||||
|         } |         } | ||||||
|  |         changed = true; | ||||||
|     } else if (key == '.') { |     } else if (key == '.') { | ||||||
|         if (value.indexOf('.') == -1) { |         if (value.indexOf('.') == -1) { | ||||||
|             quantity.text(value + '.'); |             if (changed) { | ||||||
|  |                 quantity.text(value + '.'); | ||||||
|  |             } else { | ||||||
|  |                 quantity.text('0.'); | ||||||
|  |                 changed = true; | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         if (value == '0') { |         if (value == '0') { | ||||||
|             quantity.text(key); |             quantity.text(key); | ||||||
|         } else { |             changed = true; | ||||||
|  |         } else if (changed) { | ||||||
|             quantity.text(value + key); |             quantity.text(value + key); | ||||||
|  |         } else { | ||||||
|  |             quantity.text(key); | ||||||
|  |             changed = true; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |     if (changed) { | ||||||
|  |         $('#receiving-quantity-keypad-thingy').data('changed', true); | ||||||
|  |     } | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -38,7 +38,7 @@ | ||||||
|   </tbody> |   </tbody> | ||||||
| </table> | </table> | ||||||
| 
 | 
 | ||||||
| <table id="receiving-quantity-keypad-thingy"> | <table id="receiving-quantity-keypad-thingy" data-changed="false"> | ||||||
|   <tbody> |   <tbody> | ||||||
|     <tr> |     <tr> | ||||||
|       <td>${h.link_to("7", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}</td> |       <td>${h.link_to("7", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}</td> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar