Stop using popup for expiration date, for mobile receiving

that was causing event headaches..this way is simpler
This commit is contained in:
Lance Edgar 2017-07-11 12:13:19 -05:00
parent dda79a491f
commit bf3d7b9143
2 changed files with 28 additions and 27 deletions

View file

@ -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();
});

View file

@ -79,7 +79,6 @@
${h.hidden('row', value=row.uuid)}
${h.hidden('cases')}
${h.hidden('units')}
${h.hidden('expiration_date')}
<%
uom = 'CS'
@ -97,13 +96,21 @@
<tbody>
<tr>
<td>
<fieldset data-role="controlgroup" data-type="horizontal">
<fieldset data-role="controlgroup" data-type="horizontal" class="receiving-mode">
${h.radio('mode', value='received', label="received", checked=True)}
${h.radio('mode', value='damaged', label="damaged")}
${h.radio('mode', value='expired', label="expired")}
</fieldset>
</td>
</tr>
<tr id="expiration-row" style="display: none;">
<td>
<div style="padding:10px 20px;">
<label for="expiration_date">Expiration Date</label>
<input name="expiration_date" type="date" value="" placeholder="YYYY-MM-DD" />
</div>
</td>
</tr>
<tr>
<td>
<fieldset data-role="controlgroup" data-type="horizontal" class="receiving-actions">
@ -116,14 +123,5 @@
</tbody>
</table>
<div data-role="popup" id="popup-receiving-expiration" data-dismissible="false" data-overlay-theme="b" class="ui-corner-all">
<div style="padding:10px 20px;">
<h3>Please provide expiration date</h3>
<input name="expiration-date" type="date" value="" placeholder="Expiration Date" />
<a href="#" class="ui-btn ui-btn-inline ui-corner-all" data-rel="back">Cancel</a>
<button type="button" class="ui-btn ui-btn-inline ui-corner-all">Submit</button>
</div>
</div>
${h.end_form()}
% endif