From ddb05afe6b5e0e84fda69a645733ca23a87ce139 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 6 Nov 2021 17:56:35 -0500 Subject: [PATCH] Auto-select Quantity tab when editing item for new custorder also be a little smarter on error when user selects an item --- tailbone/templates/custorders/create.mako | 21 ++++++++++++++++++--- tailbone/views/custorders/orders.py | 10 +++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/tailbone/templates/custorders/create.mako b/tailbone/templates/custorders/create.mako index f8b7b9cb..520ed0f4 100644 --- a/tailbone/templates/custorders/create.mako +++ b/tailbone/templates/custorders/create.mako @@ -489,6 +489,7 @@
@@ -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() diff --git a/tailbone/views/custorders/orders.py b/tailbone/views/custorders/orders.py index 9065c330..1cc36aca 100644 --- a/tailbone/views/custorders/orders.py +++ b/tailbone/views/custorders/orders.py @@ -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 {