Refactor "purchasing" batch views, split off "ordering"
remainder will be handled when the time comes..
This commit is contained in:
parent
4875c8ebdc
commit
d68bf6b012
6 changed files with 934 additions and 3 deletions
81
tailbone/templates/ordering/create.mako
Normal file
81
tailbone/templates/ordering/create.mako
Normal file
|
@ -0,0 +1,81 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/newbatch/create.mako" />
|
||||
|
||||
<%def name="extra_javascript()">
|
||||
${parent.extra_javascript()}
|
||||
${self.func_show_mode()}
|
||||
<script type="text/javascript">
|
||||
|
||||
var purchases_field = '${purchases_field}';
|
||||
var purchases = null; // TODO: where is this used?
|
||||
|
||||
function vendor_selected(uuid, name) {
|
||||
## var mode = $('.mode select').val();
|
||||
## if (mode == ${enum.PURCHASE_BATCH_MODE_RECEIVING} || mode == ${enum.PURCHASE_BATCH_MODE_COSTING}) {
|
||||
## var purchases = $('.purchase_uuid select');
|
||||
## purchases.empty();
|
||||
##
|
||||
## var data = {'vendor_uuid': uuid, 'mode': mode};
|
||||
## $.get('${url('purchases.batch.eligible_purchases')}', data, function(data) {
|
||||
## if (data.error) {
|
||||
## alert(data.error);
|
||||
## } else {
|
||||
## $.each(data.purchases, function(i, purchase) {
|
||||
## purchases.append($('<option value="' + purchase.key + '">' + purchase.display + '</option>'));
|
||||
## });
|
||||
## }
|
||||
## });
|
||||
##
|
||||
## // TODO: apparently refresh doesn't work right?
|
||||
## // http://stackoverflow.com/a/10280078
|
||||
## // purchases.selectmenu('refresh');
|
||||
## purchases.selectmenu('destroy').selectmenu();
|
||||
## }
|
||||
}
|
||||
|
||||
function vendor_cleared() {
|
||||
var purchases = $('.purchase_uuid select');
|
||||
purchases.empty();
|
||||
|
||||
// TODO: apparently refresh doesn't work right?
|
||||
// http://stackoverflow.com/a/10280078
|
||||
// purchases.selectmenu('refresh');
|
||||
purchases.selectmenu('destroy').selectmenu();
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
$('.field-wrapper.mode select').selectmenu({
|
||||
change: function(event, ui) {
|
||||
show_mode(ui.item.value);
|
||||
}
|
||||
});
|
||||
|
||||
// show_mode(${form.fieldset.model.mode or enum.PURCHASE_BATCH_MODE_ORDERING});
|
||||
show_mode(${enum.PURCHASE_BATCH_MODE_ORDERING});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
<%def name="func_show_mode()">
|
||||
<script type="text/javascript">
|
||||
|
||||
// TODO: mode is presumably null here..
|
||||
function show_mode(mode) {
|
||||
$('.field-wrapper.store_uuid').show();
|
||||
$('.field-wrapper.' + purchases_field).hide();
|
||||
$('.field-wrapper.department_uuid').show();
|
||||
$('.field-wrapper.buyer_uuid').show();
|
||||
$('.field-wrapper.date_ordered').show();
|
||||
$('.field-wrapper.date_received').hide();
|
||||
$('.field-wrapper.po_number').show();
|
||||
$('.field-wrapper.invoice_date').hide();
|
||||
$('.field-wrapper.invoice_number').hide();
|
||||
}
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
|
@ -1,4 +1,4 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/base.mako" />
|
||||
|
||||
<%def name="title()">Purchase Order Form</%def>
|
||||
|
@ -96,7 +96,7 @@
|
|||
|
||||
|
||||
<%def name="context_menu_items()">
|
||||
<li>${h.link_to("Back to Purchase Batch", url('purchases.batch.view', uuid=batch.uuid))}</li>
|
||||
<li>${h.link_to("Back to {}".format(model_title), url('ordering.view', uuid=batch.uuid))}</li>
|
||||
</%def>
|
||||
|
||||
|
||||
|
@ -146,7 +146,7 @@
|
|||
|
||||
${self.order_form_grid()}
|
||||
|
||||
${h.form(url('purchases.batch.order_form_update', uuid=batch.uuid), id='item-update-form', style='display: none;')}
|
||||
${h.form(url('ordering.order_form_update', uuid=batch.uuid), id='item-update-form', style='display: none;')}
|
||||
${h.csrf_token(request)}
|
||||
${h.hidden('product_uuid')}
|
||||
${h.hidden('cases_ordered')}
|
36
tailbone/templates/ordering/view.mako
Normal file
36
tailbone/templates/ordering/view.mako
Normal file
|
@ -0,0 +1,36 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/newbatch/view.mako" />
|
||||
|
||||
<%def name="extra_javascript()">
|
||||
${parent.extra_javascript()}
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
|
||||
$('#order-form').click(function() {
|
||||
% if 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?")) {
|
||||
return;
|
||||
}
|
||||
% endif
|
||||
$(this).button('disable').button('option', 'label', "Working, please wait...");
|
||||
location.href = '${url('ordering.order_form', uuid=batch.uuid)}';
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
<%def name="extra_styles()">
|
||||
${parent.extra_styles()}
|
||||
${h.stylesheet_link(request.static_url('tailbone:static/css/purchases.css'))}
|
||||
</%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">Ordering Form</button>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
Loading…
Add table
Add a link
Reference in a new issue