Add min diff threshold param when making price batch from product query

Hopefully this sets the stage for arbitrary batch params here..
This commit is contained in:
Lance Edgar 2017-01-30 16:11:29 -06:00
parent 2ab2dfe26b
commit e452ea1ae9
5 changed files with 107 additions and 57 deletions

View file

@ -7,55 +7,51 @@
<li>${h.link_to("Back to Products", url('products'))}</li>
</%def>
<%def name="head_tags()">
${parent.head_tags()}
<script type="text/javascript">
$(function() {
<%def name="extra_javascript()">
${parent.extra_javascript()}
% if legacy_mode is Undefined:
<script type="text/javascript">
$(function() {
$('#batch_type').selectmenu();
$('#batch_type').selectmenu({
change: function(event, ui) {
$('.params-wrapper').hide();
$('.params-wrapper.' + ui.item.value).show();
}
});
$('.params-wrapper.' + $('#batch_type').val()).show();
$('#make-batch').click(function() {
$(this).button('disable').button('option', 'label', "Working, please wait...");
$(this).parents('form:first').submit();
});
$('#make-batch').click(function() {
$(this).button('disable').button('option', 'label', "Working, please wait...");
$(this).parents('form:first').submit();
});
</script>
% endif
</%def>
});
</script>
<%def name="extra_styles()">
${parent.extra_styles()}
% if legacy_mode is Undefined:
<style type="text/css">
.params-wrapper {
display: none;
}
</style>
% endif
</%def>
<ul id="context-menu">
${self.context_menu_items()}
</ul>
% if supported_batches is not Undefined:
<div class="form">
${h.form(request.current_route_url())}
${h.csrf_token(request)}
<div class="form">
${h.form(request.current_route_url())}
${h.csrf_token(request)}
<div class="field-wrapper">
<label for="batch_type">Batch Type</label>
<div class="field">
${h.select('batch_type', None, supported_batches)}
</div>
</div>
<div class="buttons">
<button type="button" id="make-batch">Create Batch</button>
${h.link_to("Cancel", url('products'), class_='button')}
</div>
${h.end_form()}
</div>
% else: ## legacy mode
<div class="form">
${h.form(request.current_route_url())}
${h.csrf_token(request)}
% if legacy_mode is not Undefined:
<div class="field-wrapper">
<label for="provider">Batch Type</label>
@ -69,8 +65,24 @@
${h.link_to("Cancel", url('products'), class_='button')}
</div>
${h.end_form()}
% else: ## new-style batches
</div>
${self.wtfield(form, 'batch_type')}
% endif
% for key, pform in params_forms.items():
<div class="params-wrapper ${key}">
% for name in pform._fields:
${self.wtfield(pform, name)}
% endfor
</div>
% endfor
<div class="buttons">
<button type="button" id="make-batch">Create Batch</button>
${h.link_to("Cancel", url('products'), class_='button')}
</div>
% endif
${h.end_form()}
</div>

View file

@ -130,3 +130,12 @@
<%def name="footer()">
powered by ${h.link_to("Rattail", url('about'))}
</%def>
<%def name="wtfield(form, name, **kwargs)">
<div class="field-wrapper${' error' if form[name].errors else ''}">
<label for="${name}">${form[name].label}</label>
<div class="field">
${form[name](**kwargs)}
</div>
</div>
</%def>