Various tweaks to support mobile inventory batches
still not fully there I think, but pretty close..
This commit is contained in:
		
							parent
							
								
									452cb99349
								
							
						
					
					
						commit
						32d256932e
					
				
					 10 changed files with 341 additions and 39 deletions
				
			
		| 
						 | 
				
			
			@ -102,42 +102,49 @@ $(document).on('click', '#datasync-restart', function() {
 | 
			
		|||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// handle global keypress on receiving "row" page, for sake of scanner wedge
 | 
			
		||||
// handle global keypress on product batch "row" page, for sake of scanner wedge
 | 
			
		||||
var product_batch_routes = [
 | 
			
		||||
    'mobile.batch.inventory.view',
 | 
			
		||||
    'mobile.receiving.view',
 | 
			
		||||
];
 | 
			
		||||
$(document).on('keypress', function(event) {
 | 
			
		||||
    if ($('.ui-page-active [role="main"]').data('route') == 'mobile.receiving.view') {
 | 
			
		||||
        var upc = $('#upc-search');
 | 
			
		||||
        if (upc.length) {
 | 
			
		||||
            if (upc.is(':focus')) {
 | 
			
		||||
                if (event.which == 13) {
 | 
			
		||||
                    if (upc.val()) {
 | 
			
		||||
                        $.mobile.navigate(upc.data('url') + '?upc=' + upc.val());
 | 
			
		||||
    var current_route = $('.ui-page-active [role="main"]').data('route');
 | 
			
		||||
    for (var route of product_batch_routes) {
 | 
			
		||||
        if (current_route == route) {
 | 
			
		||||
            var upc = $('.ui-page-active #upc-search');
 | 
			
		||||
            if (upc.length) {
 | 
			
		||||
                if (upc.is(':focus')) {
 | 
			
		||||
                    if (event.which == 13) {
 | 
			
		||||
                        if (upc.val()) {
 | 
			
		||||
                            $.mobile.navigate(upc.data('url') + '?upc=' + upc.val());
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                if (event.which >= 48 && event.which <= 57) { // numeric (qwerty)
 | 
			
		||||
                    upc.val(upc.val() + event.key);
 | 
			
		||||
                    // TODO: these codes are correct for 'keydown' but apparently not 'keypress' ?
 | 
			
		||||
                    // } else if (event.which >= 96 && event.which <= 105) { // numeric (10-key)
 | 
			
		||||
                    //     upc.val(upc.val() + event.key);
 | 
			
		||||
                } else if (event.which == 13) {
 | 
			
		||||
                    if (upc.val()) {
 | 
			
		||||
                        $.mobile.navigate(upc.data('url') + '?upc=' + upc.val());
 | 
			
		||||
                } else {
 | 
			
		||||
                    if (event.which >= 48 && event.which <= 57) { // numeric (qwerty)
 | 
			
		||||
                        upc.val(upc.val() + event.key);
 | 
			
		||||
                        // TODO: these codes are correct for 'keydown' but apparently not 'keypress' ?
 | 
			
		||||
                        // } else if (event.which >= 96 && event.which <= 105) { // numeric (10-key)
 | 
			
		||||
                        //     upc.val(upc.val() + event.key);
 | 
			
		||||
                    } else if (event.which == 13) {
 | 
			
		||||
                        if (upc.val()) {
 | 
			
		||||
                            $.mobile.navigate(upc.data('url') + '?upc=' + upc.val());
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// handle numeric buttons for receiving
 | 
			
		||||
// $(document).on('click', '#receiving-quantity-keypad-thingy .ui-btn', function() {
 | 
			
		||||
$(document).on('click', '#receiving-quantity-keypad-thingy .keypad-button', function() {
 | 
			
		||||
    var quantity = $('.receiving-quantity');
 | 
			
		||||
// when numeric keypad button is clicked, update quantity accordingly
 | 
			
		||||
$(document).on('click', '.quantity-keypad-thingy .keypad-button', function() {
 | 
			
		||||
    var keypad = $(this).parents('.quantity-keypad-thingy');
 | 
			
		||||
    var quantity = keypad.find('.keypad-quantity');
 | 
			
		||||
    var value = quantity.text();
 | 
			
		||||
    var key = $(this).text();
 | 
			
		||||
    var changed = $('#receiving-quantity-keypad-thingy').data('changed');
 | 
			
		||||
    var changed = keypad.data('changed');
 | 
			
		||||
    if (key == 'Del') {
 | 
			
		||||
        if (value.length == 1) {
 | 
			
		||||
            quantity.text('0');
 | 
			
		||||
| 
						 | 
				
			
			@ -166,7 +173,7 @@ $(document).on('click', '#receiving-quantity-keypad-thingy .keypad-button', func
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (changed) {
 | 
			
		||||
        $('#receiving-quantity-keypad-thingy').data('changed', true);
 | 
			
		||||
        keypad.data('changed', true);
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -214,3 +221,17 @@ $(document).on('click', '.receiving-actions button', function() {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// handle inventory save button
 | 
			
		||||
$(document).on('click', '.inventory-actions button.save', function() {
 | 
			
		||||
    var form = $(this).parents('form:first');
 | 
			
		||||
    var uom = form.find('[name="keypad-uom"]:checked').val();
 | 
			
		||||
    var qty = form.find('.keypad-quantity').text();
 | 
			
		||||
    if (uom == 'CS') {
 | 
			
		||||
        form.find('input[name="cases"]').val(qty);
 | 
			
		||||
    } else { // units
 | 
			
		||||
        form.find('input[name="units"]').val(qty);
 | 
			
		||||
    }
 | 
			
		||||
    form.submit();
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue