Refactor mobile receiving to use "quick row" feature
plus some other random things thrown in there, for good measure..
This commit is contained in:
parent
3cc8adba86
commit
a34a42d2b2
9 changed files with 177 additions and 156 deletions
|
@ -113,7 +113,6 @@ $(document).on('click', '#datasync-restart', function() {
|
|||
// 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) {
|
||||
var current_route = $('.ui-page-active [role="main"]').data('route');
|
||||
|
@ -146,10 +145,12 @@ $(document).on('keypress', function(event) {
|
|||
});
|
||||
|
||||
|
||||
// handle ENTER press for quick_row forms
|
||||
// handle various keypress events for quick row forms
|
||||
$(document).on('keypress', function(event) {
|
||||
var quick_row = $('.ui-page-active #quick_row_entry');
|
||||
if (quick_row.length) {
|
||||
|
||||
// if user hits enter with quick row input focused, submit form
|
||||
if (quick_row.is(':focus')) {
|
||||
if (event.which == 13) { // ENTER
|
||||
if (quick_row.val()) {
|
||||
|
@ -158,6 +159,31 @@ $(document).on('keypress', function(event) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} else { // quick row input not focused
|
||||
|
||||
// mimic keyboard wedge if we're so instructed
|
||||
if (quick_row.data('wedge')) {
|
||||
|
||||
if (event.which >= 48 && event.which <= 57) { // numeric (qwerty)
|
||||
if (!event.altKey && !event.ctrlKey && !event.metaKey) {
|
||||
quick_row.val(quick_row.val() + event.key);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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) { // ENTER
|
||||
// submit form when ENTER is received via keyboard "wedge"
|
||||
if (quick_row.val()) {
|
||||
var form = quick_row.parents('form:first');
|
||||
form.submit();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue