Auto-select Quantity tab when editing item for new custorder

also be a little smarter on error when user selects an item
This commit is contained in:
Lance Edgar 2021-11-06 17:56:35 -05:00
parent 43bbc2a29e
commit ddb05afe6b
2 changed files with 25 additions and 6 deletions

View file

@ -489,6 +489,7 @@
<div class="card-content">
<b-tabs type="is-boxed is-toggle"
v-model="itemDialogTabIndex"
:animated="false">
<b-tab-item label="Product">
@ -816,6 +817,7 @@
items: ${json.dumps(order_items)|n},
editingItem: null,
showingItemDialog: false,
itemDialogTabIndex: 0,
productIsKnown: true,
productUUID: null,
productDisplay: null,
@ -1105,7 +1107,7 @@
})
},
submitBatchData(params, callback) {
submitBatchData(params, success, failure) {
let url = ${json.dumps(request.current_route_url())|n}
let headers = {
@ -1115,8 +1117,17 @@
## TODO: should find a better way to handle CSRF token
this.$http.post(url, params, {headers: headers}).then((response) => {
if (callback) {
callback(response)
if (response.data.error) {
this.$buefy.toast.open({
message: response.data.error,
type: 'is-danger',
duration: 2000, // 2 seconds
})
if (failure) {
failure(response)
}
} else if (success) {
success(response)
}
}, response => {
this.$buefy.toast.open({
@ -1377,6 +1388,7 @@
this.productPriceNeedsConfirmation = false
% endif
this.itemDialogTabIndex = 0
this.showingItemDialog = true
this.$nextTick(() => {
this.$refs.productAutocomplete.focus()
@ -1405,6 +1417,7 @@
this.productPriceNeedsConfirmation = row.price_needs_confirmation
% endif
this.itemDialogTabIndex = 1
this.showingItemDialog = true
},
@ -1492,6 +1505,8 @@
% if product_price_may_be_questionable:
this.productPriceNeedsConfirmation = false
% endif
}, response => {
this.clearProduct()
})
} else {
this.clearProduct()

View file

@ -560,9 +560,13 @@ class CustomerOrderView(MasterView):
return self.handler.uom_choices_for_product(product)
def info_for_product(self, batch, data, product):
info = self.handler.get_product_info(batch, product)
info['url'] = self.request.route_url('products.view', uuid=info['uuid'])
return info
try:
info = self.handler.get_product_info(batch, product)
except Exception as error:
return {'error': six.text_type(error)}
else:
info['url'] = self.request.route_url('products.view', uuid=info['uuid'])
return info
def normalize_batch(self, batch):
return {