Add initial support for mobile receiving views

This commit is contained in:
Lance Edgar 2017-05-24 00:04:56 -05:00
parent d68bf6b012
commit 5eca2347d5
11 changed files with 712 additions and 14 deletions

View file

@ -39,12 +39,14 @@ $(document).on('pagecreate', function() {
/**
* Automatically set focus to certain fields, on various pages
* TODO: this should accept selector params instead of hard-coding..?
*/
function setfocus() {
var el = null;
var queries = [
'#username',
'#new-purchasing-batch-vendor-text',
// '.receiving-upc-search',
];
$.each(queries, function(i, query) {
el = $(query);
@ -92,3 +94,60 @@ $(document).on('click', 'form[name="new-purchasing-batch"] [data-role="listview"
$(document).on('click', '#datasync-restart', function() {
$(this).button('disable');
});
// handle Enter press for receiving UPC lookup
$(document).on('keydown', '.receiving-upc-search', function(event) {
if (event.which == 13) {
$.mobile.navigate($(this).data('url') + '?upc=' + $(this).val());
}
});
// 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');
var value = quantity.text();
var key = $(this).text();
if (key == 'Del') {
if (value.length == 1) {
quantity.text('0');
} else {
quantity.text(value.substring(0, value.length - 1));
}
} else if (key == '.') {
if (value.indexOf('.') == -1) {
quantity.text(value + '.');
}
} else {
if (value == '0') {
quantity.text(key);
} else {
quantity.text(value + key);
}
}
});
// handle receiving action buttons
$(document).on('click', '.receiving-actions button', function() {
var action = $(this).data('action');
var form = $('form.receiving-update');
var uom = form.find('[name="receiving-uom"]').val();
var qty = form.find('.receiving-quantity').text();
if (action == 'add' || action == 'subtract') {
if (qty != '0') {
if (action == 'subtract') {
qty = '-' + qty;
}
if (uom == 'CS') {
form.find('[name="cases"]').val(qty);
} else { // units
form.find('[name="units"]').val(qty);
}
form.submit();
}
}
});