Add "mark complete" button for inventory batch row entry page

This commit is contained in:
Lance Edgar 2023-10-06 15:53:17 -05:00
parent d84b98041f
commit 2f4877a264
2 changed files with 65 additions and 16 deletions

View file

@ -3,9 +3,35 @@
<%def name="title()">Inventory Form</%def> <%def name="title()">Inventory Form</%def>
<%def name="context_menu_items()"> <%def name="object_helpers()">
${parent.context_menu_items()} <nav class="panel">
<li>${h.link_to("Back to Inventory Batch", url('batch.inventory.view', uuid=batch.uuid))}</li> <p class="panel-heading">Batch</p>
<div class="panel-block buttons">
<div style="display: flex; flex-direction: column;">
<once-button type="is-primary"
icon-left="eye"
tag="a" href="${url('batch.inventory.view', uuid=batch.uuid)}"
text="View Batch">
</once-button>
% if not batch.executed and master.has_perm('edit'):
${h.form(master.get_action_url('toggle_complete', batch), **{'@submit': 'toggleCompleteSubmitting = true'})}
${h.csrf_token(request)}
${h.hidden('complete', value='true')}
<b-button type="is-primary"
native-type="submit"
icon-pack="fas"
icon-left="check"
:disabled="toggleCompleteSubmitting">
{{ toggleCompleteSubmitting ? "Working, please wait..." : "Mark Complete" }}
</b-button>
${h.end_form()}
% endif
</div>
</div>
</nav>
</%def> </%def>
<%def name="render_form()"> <%def name="render_form()">
@ -123,6 +149,7 @@
let ${form.component_studly} = { let ${form.component_studly} = {
template: '#${form.component}-template', template: '#${form.component}-template',
mixins: [SimpleRequestMixin],
mounted() { mounted() {
this.$refs.productUPC.focus() this.$refs.productUPC.focus()
@ -195,15 +222,9 @@
let params = { let params = {
upc: this.productUPC, upc: this.productUPC,
} }
this.$http.get(url, {params: params}).then(response => { this.simpleGET(url, params, response => {
if (response.data.error) { if (response.data.product.uuid) {
alert(response.data.error)
if (response.data.redirect) {
location.href = response.data.redirect
}
} else if (response.data.product.uuid) {
this.productUPC = response.data.product.upc_pretty this.productUPC = response.data.product.upc_pretty
this.productInfo = response.data.product this.productInfo = response.data.product
@ -238,6 +259,19 @@
} else { } else {
## this.productNotFound = true ## this.productNotFound = true
alert("Product not found!") alert("Product not found!")
// focus/select UPC entry
this.$refs.productUPC.focus()
// nb. must traverse into the <b-input> element
this.$refs.productUPC.$el.firstChild.select()
}
}, response => {
if (response.data.error) {
alert(response.data.error)
if (response.data.redirect) {
location.href = response.data.redirect
}
} }
}) })
}, },
@ -263,5 +297,14 @@
</script> </script>
</%def> </%def>
<%def name="modify_this_page_vars()">
${parent.modify_this_page_vars()}
<script type="text/javascript">
ThisPageData.toggleCompleteSubmitting = false
</script>
</%def>
${parent.body()} ${parent.body()}

View file

@ -228,7 +228,7 @@ class InventoryBatchView(BatchMasterView):
Desktop workflow view for adding items to inventory batch. Desktop workflow view for adding items to inventory batch.
""" """
batch = self.get_instance() batch = self.get_instance()
if batch.executed: if batch.executed or batch.complete:
return self.redirect(self.get_action_url('view', batch)) return self.redirect(self.get_action_url('view', batch))
schema = DesktopForm().bind(session=self.Session()) schema = DesktopForm().bind(session=self.Session())
@ -360,11 +360,17 @@ class InventoryBatchView(BatchMasterView):
# TODO: deprecate / remove (?) # TODO: deprecate / remove (?)
def find_product(self, entry): def find_product(self, entry):
lookup_by_code = self.rattail_config.getbool( lookup_fields = [
'tailbone', 'inventory.lookup_by_code', default=False) 'uuid',
'_product_key_',
]
return self.handler.locate_product_for_entry( if self.rattail_config.getbool('tailbone', 'inventory.lookup_by_code',
self.Session(), entry, lookup_by_code=lookup_by_code) default=False):
lookup_fields.append('alt_code')
return self.handler.locate_product_for_entry(self.Session(), entry,
lookup_fields=lookup_fields)
def product_info(self, product): def product_info(self, product):
data = {} data = {}