Invoke handler for customer autocomplete when making new custorder
This commit is contained in:
parent
57cb787b30
commit
3b6b1aa5b6
|
@ -59,8 +59,11 @@ const TailboneAutocomplete = {
|
|||
},
|
||||
|
||||
getDisplayText() {
|
||||
if (this.assignedLabel) {
|
||||
return this.assignedLabel
|
||||
}
|
||||
if (this.selected) {
|
||||
return this.selected.label
|
||||
return this.selected.display || this.selected.label
|
||||
}
|
||||
return ""
|
||||
},
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
<b-button v-if="assignedValue || selected"
|
||||
style="width: 100%; justify-content: left;"
|
||||
@click="clearSelection()">
|
||||
{{ assignedLabel || selected.label }} (click to change)
|
||||
{{ getDisplayText() }} (click to change)
|
||||
</b-button>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
v-model="customerUUID"
|
||||
placeholder="Enter name or phone number"
|
||||
:initial-label="customerDisplay"
|
||||
serviceUrl="${url('customers.autocomplete')}"
|
||||
serviceUrl="${url('{}.customer_autocomplete'.format(route_prefix))}"
|
||||
@input="customerChanged">
|
||||
</tailbone-autocomplete>
|
||||
</b-field>
|
||||
|
|
|
@ -236,14 +236,14 @@ class CustomerOrderView(MasterView):
|
|||
|
||||
if self.handler.has_custom_product_autocomplete:
|
||||
route_prefix = self.get_route_prefix()
|
||||
autocomplete = '{}.product_autocomplete'.format(route_prefix)
|
||||
product_autocomplete = '{}.product_autocomplete'.format(route_prefix)
|
||||
else:
|
||||
autocomplete = 'products.autocomplete'
|
||||
product_autocomplete = 'products.autocomplete'
|
||||
|
||||
context = {'batch': batch,
|
||||
'normalized_batch': self.normalize_batch(batch),
|
||||
'order_items': items,
|
||||
'product_autocomplete_url': self.request.route_url(autocomplete)}
|
||||
'product_autocomplete_url': self.request.route_url(product_autocomplete)}
|
||||
return self.render_to_response(template, context)
|
||||
|
||||
def get_current_batch(self):
|
||||
|
@ -296,6 +296,15 @@ class CustomerOrderView(MasterView):
|
|||
url = self.request.route_url(route_prefix)
|
||||
return self.redirect(url)
|
||||
|
||||
def customer_autocomplete(self):
|
||||
"""
|
||||
Custom customer autocomplete logic, which invokes the handler.
|
||||
"""
|
||||
self.handler = self.get_batch_handler()
|
||||
term = self.request.GET['term']
|
||||
return self.handler.customer_autocomplete(self.Session(), term,
|
||||
user=self.request.user)
|
||||
|
||||
def get_customer_info(self, batch, data):
|
||||
uuid = data.get('uuid')
|
||||
if not uuid:
|
||||
|
@ -583,6 +592,15 @@ class CustomerOrderView(MasterView):
|
|||
route_prefix = cls.get_route_prefix()
|
||||
url_prefix = cls.get_url_prefix()
|
||||
|
||||
# customer autocomplete
|
||||
config.add_route('{}.customer_autocomplete'.format(route_prefix),
|
||||
'{}/customer-autocomplete'.format(url_prefix),
|
||||
request_method='GET')
|
||||
config.add_view(cls, attr='customer_autocomplete',
|
||||
route_name='{}.customer_autocomplete'.format(route_prefix),
|
||||
renderer='json',
|
||||
permission='customers.list')
|
||||
|
||||
# custom product autocomplete
|
||||
config.add_route('{}.product_autocomplete'.format(route_prefix),
|
||||
'{}/product-autocomplete'.format(url_prefix),
|
||||
|
|
Loading…
Reference in a new issue