Use product lookup component for "resolve pending product" tool
This commit is contained in:
parent
4809cf039e
commit
a5c1cba81b
|
@ -532,8 +532,9 @@
|
||||||
Product
|
Product
|
||||||
</p>
|
</p>
|
||||||
<tailbone-product-lookup ref="productLookup"
|
<tailbone-product-lookup ref="productLookup"
|
||||||
:selected-product="selectedProduct"
|
:product="selectedProduct"
|
||||||
@selected="productLookupSelected">
|
@selected="productLookupSelected"
|
||||||
|
autocomplete-url="${url(f'{route_prefix}.product_autocomplete')}">
|
||||||
</tailbone-product-lookup>
|
</tailbone-product-lookup>
|
||||||
</b-field>
|
</b-field>
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
<b-field grouped>
|
<b-field grouped>
|
||||||
|
|
||||||
<b-field :expanded="!selectedProduct">
|
<b-field :expanded="!product">
|
||||||
<b-autocomplete ref="productAutocomplete"
|
<b-autocomplete ref="productAutocomplete"
|
||||||
v-if="!selectedProduct"
|
v-if="!product"
|
||||||
v-model="autocompleteValue"
|
v-model="autocompleteValue"
|
||||||
placeholder="Enter UPC or brand, description etc."
|
placeholder="Enter UPC or brand, description etc."
|
||||||
:data="autocompleteOptions"
|
:data="autocompleteOptions"
|
||||||
|
@ -18,25 +18,25 @@
|
||||||
@select="autocompleteSelected"
|
@select="autocompleteSelected"
|
||||||
style="width: 100%;">
|
style="width: 100%;">
|
||||||
</b-autocomplete>
|
</b-autocomplete>
|
||||||
<b-button v-if="selectedProduct"
|
<b-button v-if="product"
|
||||||
@click="clearSelection(true)">
|
@click="clearSelection(true)">
|
||||||
{{ selectedProduct.full_description }}
|
{{ product.full_description }}
|
||||||
</b-button>
|
</b-button>
|
||||||
</b-field>
|
</b-field>
|
||||||
|
|
||||||
<b-button type="is-primary"
|
<b-button type="is-primary"
|
||||||
v-if="!selectedProduct"
|
v-if="!product"
|
||||||
@click="lookupInit()"
|
@click="lookupInit()"
|
||||||
icon-pack="fas"
|
icon-pack="fas"
|
||||||
icon-left="search">
|
icon-left="search">
|
||||||
Full Lookup
|
Full Lookup
|
||||||
</b-button>
|
</b-button>
|
||||||
|
|
||||||
<b-button v-if="selectedProduct"
|
<b-button v-if="product"
|
||||||
type="is-primary"
|
type="is-primary"
|
||||||
tag="a" target="_blank"
|
tag="a" target="_blank"
|
||||||
:href="selectedProduct.url"
|
:href="product.url"
|
||||||
:disabled="!selectedProduct.url"
|
:disabled="!product.url"
|
||||||
icon-pack="fas"
|
icon-pack="fas"
|
||||||
icon-left="external-link-alt">
|
icon-left="external-link-alt">
|
||||||
View Product
|
View Product
|
||||||
|
@ -209,9 +209,13 @@
|
||||||
const TailboneProductLookup = {
|
const TailboneProductLookup = {
|
||||||
template: '#tailbone-product-lookup-template',
|
template: '#tailbone-product-lookup-template',
|
||||||
props: {
|
props: {
|
||||||
selectedProduct: {
|
product: {
|
||||||
type: Object,
|
type: Object,
|
||||||
},
|
},
|
||||||
|
autocompleteUrl: {
|
||||||
|
type: String,
|
||||||
|
default: '${url('products.autocomplete')}',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -238,7 +242,7 @@
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
focus() {
|
focus() {
|
||||||
if (!this.selectedProduct) {
|
if (!this.product) {
|
||||||
this.$refs.productAutocomplete.focus()
|
this.$refs.productAutocomplete.focus()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -269,8 +273,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// and perform the search
|
// and perform the search
|
||||||
let url = '${url(f'{route_prefix}.product_autocomplete')}'
|
this.$http.get(this.autocompleteUrl + '?term=' + encodeURIComponent(entry))
|
||||||
this.$http.get(url + '?term=' + encodeURIComponent(entry))
|
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
this.autocompleteOptions = data
|
this.autocompleteOptions = data
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
@ -283,6 +286,8 @@
|
||||||
this.$emit('selected', {
|
this.$emit('selected', {
|
||||||
uuid: option.value,
|
uuid: option.value,
|
||||||
full_description: option.label,
|
full_description: option.label,
|
||||||
|
url: option.url,
|
||||||
|
image_url: option.image_url,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
## -*- coding: utf-8; -*-
|
## -*- coding: utf-8; -*-
|
||||||
<%inherit file="/master/view.mako" />
|
<%inherit file="/master/view.mako" />
|
||||||
|
<%namespace name="product_lookup" file="/products/lookup.mako" />
|
||||||
|
|
||||||
|
<%def name="render_this_page_template()">
|
||||||
|
${parent.render_this_page_template()}
|
||||||
|
${product_lookup.tailbone_product_lookup_template()}
|
||||||
|
</%def>
|
||||||
|
|
||||||
<%def name="object_helpers()">
|
<%def name="object_helpers()">
|
||||||
${parent.object_helpers()}
|
${parent.object_helpers()}
|
||||||
|
@ -43,12 +49,13 @@
|
||||||
<span>${instance.full_description}</span>
|
<span>${instance.full_description}</span>
|
||||||
</b-field>
|
</b-field>
|
||||||
<b-field label="Actual Product" expanded>
|
<b-field label="Actual Product" expanded>
|
||||||
<tailbone-autocomplete name="product_uuid"
|
<tailbone-product-lookup ref="productLookup"
|
||||||
v-model="resolveProductUUID"
|
autocomplete-url="${url('products.autocomplete_special', key='with_key')}"
|
||||||
ref="resolveProductAutocomplete"
|
:product="actualProduct"
|
||||||
service-url="${url('products.autocomplete')}">
|
@selected="productSelected">
|
||||||
</tailbone-autocomplete>
|
</tailbone-product-lookup>
|
||||||
</b-field>
|
</b-field>
|
||||||
|
${h.hidden('product_uuid', **{':value': 'resolveProductUUID'})}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<footer class="modal-card-foot">
|
<footer class="modal-card-foot">
|
||||||
|
@ -91,7 +98,7 @@
|
||||||
this.resolveProductUUID = null
|
this.resolveProductUUID = null
|
||||||
this.resolveProductShowDialog = true
|
this.resolveProductShowDialog = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.resolveProductAutocomplete.focus()
|
this.$refs.productLookup.focus()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +107,20 @@
|
||||||
this.$refs.resolveProductForm.submit()
|
this.$refs.resolveProductForm.submit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThisPageData.actualProduct = null
|
||||||
|
|
||||||
|
ThisPage.methods.productSelected = function(product) {
|
||||||
|
this.actualProduct = product
|
||||||
|
this.resolveProductUUID = product ? product.uuid : null
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
<%def name="make_this_page_component()">
|
||||||
|
${parent.make_this_page_component()}
|
||||||
|
${product_lookup.tailbone_product_lookup_component()}
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
|
||||||
${parent.body()}
|
${parent.body()}
|
||||||
|
|
Loading…
Reference in a new issue