Refactor ordering worksheet to use shared logic

This commit is contained in:
Lance Edgar 2018-02-19 18:19:19 -06:00
parent b529a005d8
commit 1b059c5293
4 changed files with 12 additions and 28 deletions

View file

@ -6,8 +6,8 @@
<script type="text/javascript">
$(function() {
$('#order-form').click(function() {
% if vendor_cost_count > vendor_cost_threshold:
$('.load-worksheet').click(function() {
% if vendor_cost_count is not Undefined and vendor_cost_threshold is not Undefined and vendor_cost_count > vendor_cost_threshold:
if (! confirm("This vendor has ${'{:,d}'.format(vendor_cost_count)} cost records.\n\n" +
"It is not recommended to use Order Form mode for such a large catalog.\n\n" +
"Are you sure you wish to do it anyway?")) {
@ -15,7 +15,7 @@
}
% endif
$(this).button('disable').button('option', 'label', "Working, please wait...");
location.href = '${url('ordering.order_form', uuid=batch.uuid)}';
location.href = '${url('ordering.worksheet', uuid=batch.uuid)}';
});
});
@ -34,10 +34,4 @@
% endif
</%def>
<%def name="leading_buttons()">
% if not batch.complete and not batch.executed and request.has_perm('ordering.order_form'):
<button type="button" id="order-form">Edit as Worksheet</button>
% endif
</%def>
${parent.body()}

View file

@ -158,7 +158,7 @@
${self.order_form_grid()}
${h.form(url('ordering.order_form_update', uuid=batch.uuid), id='item-update-form', style='display: none;')}
${h.form(url('ordering.worksheet_update', uuid=batch.uuid), id='item-update-form', style='display: none;')}
${h.csrf_token(request)}
${h.hidden('product_uuid')}
${h.hidden('cases_ordered')}