Allow vendor field to be dropdown, for mobile ordering/receiving
based on config. useful for apps which have very few vendors
This commit is contained in:
parent
19080924d5
commit
145e7f5529
|
@ -15,6 +15,13 @@ $(document).on('autocompleteitemselected', 'form[name="new-receiving-batch"] .ve
|
|||
$(document).on('autocompleteitemcleared', 'form[name="new-receiving-batch"] .vendor', function(event) {
|
||||
$('#new-receiving-types').hide();
|
||||
});
|
||||
$(document).on('change', 'form[name="new-receiving-batch"] select[name="vendor"]', function(event) {
|
||||
if ($(this).val()) {
|
||||
$('#new-receiving-types').show();
|
||||
} else {
|
||||
$('#new-receiving-types').hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// submit new receiving batch form when user clicks "Receive" type button
|
||||
|
|
|
@ -9,12 +9,21 @@ ${h.form(request.current_route_url(), class_='ui-filterable', name='new-purchasi
|
|||
${h.csrf_token(request)}
|
||||
|
||||
<div class="field-wrapper vendor">
|
||||
<div class="field autocomplete" data-url="${url('vendors.autocomplete')}">
|
||||
${h.hidden('vendor')}
|
||||
${h.text('new-purchasing-batch-vendor-text', placeholder="Vendor name", autocomplete='off', data_type='search')}
|
||||
<ul data-role="listview" data-inset="true" data-filter="true" data-input="#new-purchasing-batch-vendor-text"></ul>
|
||||
<button type="button" style="display: none;">Change Vendor</button>
|
||||
</div>
|
||||
% if vendor_use_autocomplete:
|
||||
<div class="field autocomplete" data-url="${url('vendors.autocomplete')}">
|
||||
${h.hidden('vendor')}
|
||||
${h.text('new-purchasing-batch-vendor-text', placeholder="Vendor name", autocomplete='off', data_type='search')}
|
||||
<ul data-role="listview" data-inset="true" data-filter="true" data-input="#new-purchasing-batch-vendor-text"></ul>
|
||||
<button type="button" style="display: none;">Change Vendor</button>
|
||||
</div>
|
||||
% else:
|
||||
<div class="field-row">
|
||||
<label for="vendor">Vendor</label>
|
||||
<div class="field">
|
||||
${h.select('vendor', None, vendor_options)}
|
||||
</div>
|
||||
</div>
|
||||
% endif
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
|
|
@ -10,14 +10,23 @@ ${h.csrf_token(request)}
|
|||
|
||||
% if phase == 1:
|
||||
|
||||
<div class="field-wrapper vendor">
|
||||
<div class="field autocomplete" data-url="${url('vendors.autocomplete')}">
|
||||
${h.hidden('vendor')}
|
||||
${h.text('new-receiving-batch-vendor-text', placeholder="Vendor name", autocomplete='off', **{'data-type': 'search'})}
|
||||
<ul data-role="listview" data-inset="true" data-filter="true" data-input="#new-receiving-batch-vendor-text"></ul>
|
||||
<button type="button" style="display: none;">Change Vendor</button>
|
||||
</div>
|
||||
</div>
|
||||
% if vendor_use_autocomplete:
|
||||
<div class="field-wrapper vendor">
|
||||
<div class="field autocomplete" data-url="${url('vendors.autocomplete')}">
|
||||
${h.hidden('vendor')}
|
||||
${h.text('new-receiving-batch-vendor-text', placeholder="Vendor name", autocomplete='off', **{'data-type': 'search'})}
|
||||
<ul data-role="listview" data-inset="true" data-filter="true" data-input="#new-receiving-batch-vendor-text"></ul>
|
||||
<button type="button" style="display: none;">Change Vendor</button>
|
||||
</div>
|
||||
</div>
|
||||
% else:
|
||||
<div class="field-row">
|
||||
<label for="vendor">Vendor</label>
|
||||
<div class="field">
|
||||
${h.select('vendor', None, vendor_options)}
|
||||
</div>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
<br />
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2017 Lance Edgar
|
||||
# Copyright © 2010-2019 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -36,6 +36,8 @@ from rattail.db import model, api
|
|||
from rattail.core import Object
|
||||
from rattail.time import localtime
|
||||
|
||||
from webhelpers2.html import tags
|
||||
|
||||
from tailbone.views.purchasing import PurchasingBatchView
|
||||
|
||||
|
||||
|
@ -317,6 +319,17 @@ class OrderingBatchView(PurchasingBatchView):
|
|||
data['index_title'] = self.get_index_title()
|
||||
data['index_url'] = self.get_index_url(mobile=True)
|
||||
data['mode_title'] = self.enum.PURCHASE_BATCH_MODE[mode].capitalize()
|
||||
|
||||
data['vendor_use_autocomplete'] = self.rattail_config.getbool(
|
||||
'rattail', 'vendor.use_autocomplete', default=True)
|
||||
if not data['vendor_use_autocomplete']:
|
||||
vendors = self.Session.query(model.Vendor)\
|
||||
.order_by(model.Vendor.name)
|
||||
options = [(tags.Option(vendor.name, vendor.uuid))
|
||||
for vendor in vendors]
|
||||
options.insert(0, tags.Option("(please choose)", ''))
|
||||
data['vendor_options'] = options
|
||||
|
||||
return self.render_to_response('create', data, mobile=True)
|
||||
|
||||
def configure_mobile_row_form(self, f):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2018 Lance Edgar
|
||||
# Copyright © 2010-2019 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -677,10 +677,23 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
data['dform'] = form.make_deform_form()
|
||||
data['mode_title'] = self.enum.PURCHASE_BATCH_MODE[mode].capitalize()
|
||||
data['phase'] = phase
|
||||
if phase == 2:
|
||||
|
||||
if phase == 1:
|
||||
data['vendor_use_autocomplete'] = self.rattail_config.getbool(
|
||||
'rattail', 'vendor.use_autocomplete', default=True)
|
||||
if not data['vendor_use_autocomplete']:
|
||||
vendors = self.Session.query(model.Vendor)\
|
||||
.order_by(model.Vendor.name)
|
||||
options = [(tags.Option(vendor.name, vendor.uuid))
|
||||
for vendor in vendors]
|
||||
options.insert(0, tags.Option("(please choose)", ''))
|
||||
data['vendor_options'] = options
|
||||
|
||||
elif phase == 2:
|
||||
purchases = self.eligible_purchases(vendor.uuid, mode=mode)
|
||||
data['purchases'] = [(p['key'], p['display']) for p in purchases['purchases']]
|
||||
data['purchase_order_fieldname'] = self.purchase_order_fieldname
|
||||
|
||||
return self.render_to_response('create', data, mobile=True)
|
||||
|
||||
def make_mobile_receiving_from_po_schema(self):
|
||||
|
|
Loading…
Reference in a new issue