Stop using popup for expiration date, for mobile receiving
that was causing event headaches..this way is simpler
This commit is contained in:
parent
dda79a491f
commit
bf3d7b9143
2 changed files with 28 additions and 27 deletions
tailbone/static/js
|
@ -151,6 +151,17 @@ $(document).on('click', '#receiving-quantity-keypad-thingy .keypad-button', func
|
|||
});
|
||||
|
||||
|
||||
// show/hide expiration date per receiving mode selection
|
||||
$(document).on('change', 'fieldset.receiving-mode input[name="mode"]', function() {
|
||||
var mode = $(this).val();
|
||||
if (mode == 'expired') {
|
||||
$('#expiration-row').show();
|
||||
} else {
|
||||
$('#expiration-row').hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// handle receiving action buttons
|
||||
$(document).on('click', '.receiving-actions button', function() {
|
||||
var action = $(this).data('action');
|
||||
|
@ -171,23 +182,15 @@ $(document).on('click', '.receiving-actions button', function() {
|
|||
}
|
||||
|
||||
if (action == 'add' && mode == 'expired') {
|
||||
$('#popup-receiving-expiration').popup('open');
|
||||
} else {
|
||||
form.submit();
|
||||
var expiry = form.find('input[name="expiration_date"]');
|
||||
if (! /^\d{4}-\d{2}-\d{2}$/.test(expiry.val())) {
|
||||
alert("Please enter a valid expiration date.");
|
||||
expiry.focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
form.submit();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// TODO: something's wrong.. we can't close the popup or else the form will
|
||||
// be "posted" via GET. but then we still have to click the button twice??
|
||||
|
||||
// handle Submit button from receiving expiration date popup
|
||||
$(document).on('click', '#popup-receiving-expiration button', function() {
|
||||
var popup = $('#popup-receiving-expiration');
|
||||
var date = popup.find('input').val();
|
||||
var form = $('form.receiving-update');
|
||||
form.find('[name="expiration_date"]').val(date);
|
||||
form.submit();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue